In this article, I have explained the procedure to create a notepad application.
Introduction
This is a simple window application, which explains how to create a Notepad application.
Description
To create a notepad application, the primary requirements are to place a MenuBar control and a textbox control. A menubar is a collection of menu's and a menu is a collection of menu items.
To create a simple notepad application, create a new project with a name NotepadApp and design the window as shown below.


According to your requirement, you can add the submenus in a menu as shown in the above image.
In my application, I have added File, Edit, Format, Help menus in a menu control.
Under File menu: New, Open, Save, Print, Exit.
Under Edit menu: Cut, Copy, Paste, SelectAll.
Under Format menu: Font, Color.
Under Help menu: AboutUs.
Set the textbox property as : Name = txtContent, Dock = Fill and Multiline = true.
To work with the above applicaion, 7 controls are required that is
• OpenFileDialog control : This control is used here to print an open dialog box.
• SaveFileDialog control : This control is used here to print a file dialog box.
• PrintDialog control : This control is used here to print a print dialog box.
• FontDialog control : This control is used here to print a font dialog box.
• ColorDialog control : This control is used here to print a color dialog box.
• MenuStrip control : This is used here to add different menu items.
So to add the above controls, Go to the tool box and add accordingly the controls as mentioned. Below is the image.

Code to work with above Requirement
using
System;using
System.Collections.Generic;using
System.ComponentModel;using
System.Data;using
System.Drawing;using
System.Linq;using
System.Text;using
System.Windows.Forms;using
System.IO;
namespace
NotepadApp{
public partial class Form1 : Form{
public Form1(){
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e){
}
private void newToolStripMenuItem_Click(object sender, EventArgs e){
txtContent.Text =
"";}
private void openToolStripMenuItem_Click(object sender, EventArgs e){
openFileDialog1.ShowDialog();
//Now it show open dialog box.//Read the filename selected by the user with in open file dialog box.string fName = openFileDialog1.FileName;//Read the data by using StreamReader classStreamReader sr = new StreamReader(fName);txtContent.Text = sr.ReadToEnd();
sr.Close();
}
private void saveToolStripMenuItem_Click(object sender, EventArgs e){
saveFileDialog1.ShowDialog();
string fName = saveFileDialog1.FileName;StreamWriter sw = new StreamWriter(fName);sw.Write(txtContent.Text);
sw.Flush();
sw.Close();
}
private void printToolStripMenuItem_Click(object sender, EventArgs e){
printDialog1.ShowDialog();
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e){
Application.Exit();}
private void cutToolStripMenuItem_Click(object sender, EventArgs e){
txtContent.Cut();
}
private void copyToolStripMenuItem_Click(object sender, EventArgs e){
txtContent.Copy();
}
private void pasteToolStripMenuItem_Click(object sender, EventArgs e){
txtContent.Paste();
}
private void selectAllToolStripMenuItem_Click(object sender, EventArgs e){
txtContent.SelectAll();
}
private void fontToolStripMenuItem_Click(object sender, EventArgs e){
fontDialog1.ShowDialog();
txtContent.Font = fontDialog1.Font;
}
private void colorToolStripMenuItem_Click(object sender, EventArgs e){
colorDialog1.ShowDialog();
txtContent.ForeColor = colorDialog1.Color;
}
private void aboutUsToolStripMenuItem_Click(object sender, EventArgs e){
//create a form dynamically which displays the information about the company.Form f = new Form();Label ll = new Label();ll.Text =
"Write information about the company";ll.Font =
new Font("Arial", 20);ll.Dock =
DockStyle.Fill;f.Controls.Add(ll);
f.Show();
}
}
}
Here I have used StreamReader class to read the data present with in the specified file. To work with this, we need to import the "System.IO" namespace.
The output window will look like as below image.

Suppose you want to open an existing file then click File menu>> click Open. It will look like as below image.

Conclusion
Hope you will enjoy by reading this article.