O'Reilly logo

Graphics Programming with GDI+ by Mahesh Chand

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

11.6. Printing Text

So far we have printed simple text and graphics items from the program itself. How about reading a text file and printing it from our program? Do you remember the GDI+ editor from Chapter 5? We can make the editor open a text file and add print functionality to print the text file. In this section we will read a text file and print it.

As usual, we create a Windows application and add a reference to the System.Drawing.Printing namespace. We then add a text box and four buttons to the form. We also change the Name and Text properties of the button controls. The final form looks like Figure 11.12. As you might guess, the Browse Text File button allows us to browse for text files.

Figure 11.12. The form with text file printing ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required