CommonDialog Classes
Many applications perform similar functions, such as opening and saving files, or selecting fonts. Ever since Windows 3.1, the Windows API has provided standard dialog boxes to perform many of these common operations. Not only does this save the developer from having to reinvent the wheel, but, more importantly. Providing a common dialog used by all applications means that users have to learn how to perform each function only once.
The .NET Framework provides five common dialog boxes. These dialogs are contained in classes that derive from the System.Windows.Forms.CommonDialog class. They are:
FileDialog
ColorDialog
FontDialog
PageSetupDialog
PrintDialog
The common dialogs share many properties, methods and events, some of which are listed in Table 6-5.
Table 6-5. CommonDialog common properties, methods, and events
Member |
Type |
Description |
---|---|---|
Container |
Public Property |
Returns the IContainer that contains the dialog box. |
Reset |
Public Method |
Resets the properties of the dialog box to its default values. |
ShowDialog |
Public Method |
Runs the common dialog box. |
HelpRequest |
Public Event |
Raised when user clicks the Help button of a common dialog box. |
The following sections describe each of the common dialogs provided in the CommonDialog class. A single example is used to demonstrate all of the common dialogs. The example consists of a form with a TextBox control for entering and editing text. The form has buttons for opening and loading a file into the TextBox and ...
Get Programming .NET Windows Applications 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.