Beginning Visual C#supAND#174;/sup 2005

A dialog is a window that is displayed within the context of another window. With a dialog, you can ask the user to enter some data before the flow of the program continues. A common dialog is a dialog used to get information from the user that most applications will typically require, such as the name of a file, and is a part of the Windows operating system.

The classes you get with the Microsoft .NET Framework are shown in Figure 16-1.

Figure 16-1

All these dialog classes, except the PrintPreviewDialog, derive from the abstract CommonDialog base class that has methods to manage a Windows common dialog.

The CommonDialog class defines the following methods and events common to all common dialog classes.

Public Instance Methods and Events

Description

ShowDialog()

This method is implemented from the derived class to display a common dialog.

Reset()

Every derived dialog class implements the Reset() method to set all properties of the dialog class to their default values.

HelpRequest

This event is thrown when the user clicks the Help button on a common dialog.

All these dialog classes wrap up a Windows common dialog to make the dialog available for .NET applications. PrintPreviewDialog is an exception because it adds its own elements to a Windows form to control the preview of a print, and hence is not really a dialog at all. the OpenFileDialog and SaveFileDialog classes derive from the abstract base class FileDialog that adds file features that are common to both the opening and closing file dialogs.

The following list provides an overview of how the different dialogs can be used:

Категории