Chapter 8. Using Standard Dialogs

A huge number of applications need to display dialogs to enable users to select certain standard pieces of information. Two of the most common dialogs enable users to select a file to open and select a file to save into. Other dialogs enable users to select colors, filesystem folders, fonts, and printers for printing.

Closely related to the Print dialog are the Print Preview dialog (which enables users to see a preview of a document before sending it to the printer, possibly saving paper if the user then cancels the document) and the Page Setup dialog (which enables users to modify things like margins before printing).

You could build all of these dialogs yourself (or you will be able to once you've finished reading this book), but fortunately you don't need to do that. Because many programs need the exact same features, Microsoft has provided standard dialogs that everyone can use.

Visual Basic comes with the following standard dialogs that handle these common tasks:

  • ColorDialog

  • FolderBrowserDialog

  • FontDialog

  • OpenFileDialog

  • PageSetupDialog

  • PrintDialog

  • PrintPreviewDialog

  • SaveFileDialog

Note

You might remember that in Lesson 1 I said that normally you don't need to worry about whether a feature is provided by Visual Studio, the Visual Basic language, or the .NET Framework. That's true here as well, but it's informative to note that these dialogs are actually provided by the .NET Framework, not Visual Basic. That doesn't change the way you use them, but it means ...

Get Stephens' Visual Basic® Programming 24-Hour Trainer now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.