If there is one thing the typical business computer user needs more than anything else, it’s reports. Any readers who have worked in the IS or IT department of a large organization can quickly attest to that. And reports mean printing, and printing means pain. At least, that’s what I’ve always found. Certainly, there are many third-party reporting tools available, such as the version of Crystal Reports included with Visual Studio. But these “banded” reports don’t always meet your needs. Sometimes you need to print out some text or graphics formatted in unique and custom ways.
Fortunately, the printing tools included with .NET are powerful, easy to use, and—dare I say it—fun. All of the text and graphics tools you use to update the display with .NET’s GDI+ library can be leveraged for printing purposes. The printing commands aren’t just similar to those used for screen updates; they’re actually the same commands. (Chapter 9 includes many examples that use the graphics tools included with GDI+, so such examples won’t be replicated in this chapter.)
You want to access a list of the printers available to the current Windows user.
The “printing” section of GDI+, the .NET drawing system, includes a list of the installed printers. Use the following code to display the names of each:
For Each printerName As String In _ System.Drawing.Printing.PrinterSettings.InstalledPrinters MsgBox(printerName) Next printerName