Microsoft Visual Basic 2010 Step by Step eBook

(Tina Meador) #1

Chapter 17 Working with Printers 425



  1. Click the RichTextBox control in the Toolbox, and then draw a rich text box object that
    covers the bottom half of the form.

  2. Double-click the OpenFileDialog control on the Dialogs tab to add an open file dialog
    object to the component tray below your form.
    You’ll use the open file dialog object to browse for text files on your system.

  3. Double-click the PrintDocument control on the Printing tab to add a print document
    object to the component tray.
    You’ll use the print document object to support printing in your application.

  4. Double-click the PrintDialog control on the Printing tab to add a print dialog object to
    the component tray.
    You’ll use the print dialog object to open a Print dialog box in your program.

  5. Now set the following properties for the objects on your form:


Object Property Setting
Button1 Name
Text

btnOpen
“Open”
Button2 Name
Enabled
Text

btnPrint
False
“Print”
Form1 Text “Print File”

Your form looks something like this:

Now add the program code necessary to open the text file and print it.


  1. Double-click the Open button.


The btnOpen_Click event procedure appears in the Code Editor.
Free download pdf