1 of 11

Microsoft Word Application

2 of 11

Objectives

  • Today we will implement a Rich Text Format(.rtf) saving system in our Word Application�

3 of 11

Rich Text File Save Overview

  • Saving a Rich Text File (.rtf) is similar to saving a text file (.txt)�
  • You must use:
    • A Stream Writer to output text/pictures to the document
    • Save File Dialog - Chooses the location on computer to save the document
    • Exception catches for catching errors

4 of 11

Rich Text File Save Overview Continued

  • Things to modify in program:�
    • Streamwriter
      • Use indexes to find what file format a user wants to save the document as
        • .txt, .rtf, etc

5 of 11

File Filter Index

  • File Filter Index - the default index of the first item in the SaveFileDialog filter drop-down list is 1�
    • ex) txt files (*.txt)�
  • The second index is:
    • Rtf Files (*.rtf)

6 of 11

File Filter Index

Indexes

7 of 11

File Filter Index

Index 1

Index 2

8 of 11

Save File Dialog Control (new)

  • Saves a file

9 of 11

Text Writing Methods

  • RichTextBox’s have a property called “RTF”, it includes all rich text format (RTF) codes
  • We can use SteamReader and StreamWriter to load and write the RTF text

10 of 11

Text Writing Vs. Rich Text Format Writing

  • If we want to display only text in a document we can use the following code:���
  • Otherwise if you want to display rich text format items you can use the following code:

11 of 11

It’s Your Turn!

  • Students will modify their program to save documents in a rich text format�
  • Your program should now be able to:
    • Save both text and pictures