C# Windows Forms Programming
Learn C# (C sharp) in FREE step-by-step lessons.
Zebra Notes: Open, Save, Save As, and Format with a Rich Text Box
In this lesson we will create an application similar to notepad, but we will use a RichTextBox
so that you can format the text to make it bold, italics, etc.
The file type that we will create is rtf.

Please study the material at each of the links below.
Build the Form: Show all the controls and properties for this project
/csharp/videos/csharp-standardmenu.mp4
- Declare variables to track changes.: In order to remind the user to save, we use a Boolean variable changed
- Resize: Rich text box fills the form.: Richtext box fills the lower part of the form: between the toolstrip and the statusbar
- Display the date and time on timer tick.: Timer event: toolStripStatusDateTime.Text = System.DateTime.Now.ToString();
- Save the file as rtf.: Code for function to save the contents of the richtext box to file
- Do you want to save?: If there have been changes warn user when they select New, Open, or exit program.
- Remind to save before closing.: Code to cancel closing the form if user wants to save first.
- Remind to save before Opening new file.: Code to open a new file and load it asks about saving first
- Remind to save when selecting New.: On selecting new, first ask about saving (if changes), then clear text and filename
- Change font of selected text.: Uses the Font Dialog to select font
- Change color of selected text.: Uses the Color Dialog to select color of selected text
- Using clipboard to copy, cut and paste.: Code implements copy, cut and paste using the clipboard
Using a context menu to copy, cut and paste.: A context menu is a pop-up menu that appears on right click
/csharp/videos/csharp-contextmenu.mp4
- Finishing touches: Finishing touches include adding icon, about box, and removing unused menu items
Glossary for richtext lessonFull Glossary