Fargona davlat universiteti matematika-informatika fakulteti


if (ofd.ShowDialog() == DialogResult.OK) { using


Download 378.68 Kb.
bet9/11
Sana05.01.2023
Hajmi378.68 Kb.
#1079990
1   2   3   4   5   6   7   8   9   10   11
Bog'liq
dasturlash Obidjonova

if (ofd.ShowDialog() == DialogResult.OK)
{
using (StreamReader sr = new StreamReader(ofd.FileName))
{
filePath = ofd.FileName;
Task text = sr.ReadToEndAsync();
richTextBox1.Text = text.Result;
}
}
}
}

private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
// saqlash
if (string.IsNullOrEmpty(filePath))
{
using (SaveFileDialog sfd = new SaveFileDialog() { Filter = "TextDocument|*.txt", ValidateNames = true })

if (sfd.ShowDialog() == DialogResult.OK)
{
using (StreamWriter sw = new StreamWriter(sfd.FileName))
{
sw.WriteLineAsync(richTextBox1.Text);
}
}
}
}
else{
using (StreamWriter sw = new StreamWriter(filePath))
{
sw.WriteLineAsync(richTextBox1.Text);
}
}
}

private void printPreviewToolStripMenuItem_Click(object sender, EventArgs e)
{
printPreviewDialog1.Document = printDocument1;
printPreviewDialog1.ShowDialog();
}

private void printToolStripMenuItem_Click(object sender, EventArgs e)
{
printPreviewDialog1.Document = printDocument1;
if (printDialog1.ShowDialog() == DialogResult.OK)
{
printDocument1.Print();
}
}

private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
//close window
this.Close();
}

private void undoToolStripMenuItem_Click(object sender, EventArgs e)
{
// undan oldingi xolatga qaytarish
richTextBox1.Undo();
}

private void redoToolStripMenuItem_Click(object sender, EventArgs e)
{
// kegingiga o`tish
richTextBox1.Redo();
}


Download 378.68 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8   9   10   11




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling