Zebra0.com

csharp richtextC# Windows Forms Programming

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 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.

  1. Microsoft Reference Microsoft Reference: The Rich Text Box Overview

  2. Build the Form Build the Form: Show all the controls and properties for this project
    /csharp/videos/csharp-standardmenu.mp4
  3. Declare variables to track changes.: In order to remind the user to save, we use a Boolean variable changed

  4. Resize: Rich text box fills the form.: Richtext box fills the lower part of the form: between the toolstrip and the statusbar

  5. Display the date and time on timer tick.: Timer event: toolStripStatusDateTime.Text = System.DateTime.Now.ToString();

  6. Save the file as rtf.: Code for function to save the contents of the richtext box to file

  7. Do you want to save?: If there have been changes warn user when they select New, Open, or exit program.

  8. Remind to save before closing.: Code to cancel closing the form if user wants to save first.

  9. Remind to save before Opening new file.: Code to open a new file and load it asks about saving first

  10. Remind to save when selecting New.: On selecting new, first ask about saving (if changes), then clear text and filename

  11. Change font of selected text.: Uses the Font Dialog to select font

  12. Change color of selected text.: Uses the Color Dialog to select color of selected text

  13. Using clipboard to copy, cut and paste.: Code implements copy, cut and paste using the clipboard

  14. Using a context menu to copy, cut and paste. 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
  15. Finishing touches: Finishing touches include adding icon, about box, and removing unused menu items

GlossaryGlossary for richtext lesson
Full Glossary