We need textBox, menuStrip, openFileDialog saveFileDialog, colorDialog, fontDialog to program a NotePad.
private void copyToolStripMenuItem_Click(object sender, EventArgs e)
{
textBox1.Copy();
}
private void pasteToolStripMenuItem1_Click(object sender, EventArgs e)
{
textBox1.Paste();
}
private void cutToolStripMenuItem_Click(object sender, EventArgs e)
{
textBox1.Cut();
}
private void selectAllToolStripMenuItem_Click(object sender, EventArgs e)
{
textBox1.SelectAll();
}
private void fontToolStripMenuItem_Click(object sender, EventArgs e)
{
fontDialog1.ShowDialog();
textBox1.Font = fontDialog1.Font;
}
private void foreColorToolStripMenuItem_Click(object sender, EventArgs e)
{
colorDialog1.ShowDialog();
textBox1.ForeColor = colorDialog1.Color;
}
private void backColorToolStripMenuItem_Click(object sender, EventArgs e)
{
colorDialog1.ShowDialog();
textBox1.BackColor = colorDialog1.Color;
}
private void newToolStripMenuItem_Click(object sender, EventArgs e)
{
textBox1.Clear();
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
saveFileDialog1.ShowDialog();
StreamWriter sw = new StreamWriter(saveFileDialog1.FileName);
sw.WriteLine(textBox1.Text);
sw.Flush();
sw.Close();
}
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog();
StreamReader sr = new StreamReader(openFileDialog1.FileName);
string text1 = sr.ReadToEnd();
textBox1.Text = text1;
sr.Close();
}
Download NotePad That We Just Program