Dialog Boxes

When an application needs to prompt a user for input, a dialog box is often used. Several dialog box components are provided within the Windows forms library, or you can create a custom dialog box if necessary.

Common Dialog Boxes

The Windows forms library provides several ready-made dialog boxes for Windows applications, including the following:

  • ColorDialog Displays a list of colors and returns a property containing the selected color .

  • FontDialog Allows the user to select a font and to set its properties, such as size, style, and special effects.

  • OpenFileDialog Allows the user to browse files and folders on his or her computer and select one or more.

  • PageSetupDialog Allows the user to select various page layout settings.

  • PrintDialog Allows the user to select various print options and send the specified document to the selected printer.

  • PrintPreviewDialog Allows the user to preview a file before printing.

  • SaveFileDialog Allows the user to browse the files and folders on his or her computer and select a name for a file to be saved.

These classes are also referred to as Windows forms dialog components. You will recognize many of these from your experience with the Windows operating system and Microsoft products such as the Office suite. The dialog classes are derived from the CommonDialog class, which provides the basic functionality for displaying a dialog box.

Each dialog class provides a method named ShowDialog that presents the dialog box. Each of the dialog classes has a set of properties that stores the data relevant to its particular type.

Modal and Modeless Dialog Boxes

When a modal dialog box is open , the application can only receive input for the modal dialog box and the code that called the box remains suspended . If a user wants to work with other windows, he or she must close the modal dialog box first. By contrast, a modeless dialog box allows the application to receive input for other windows while the dialog box remains open.

graphics/tip_icon.gif

When the ShowDialog method of the Form class is used, a modal dialog box will be displayed. If you would like to display a modeless dialog box, use the Show method instead.




Developing and Implementing WindowsR-based Applications with Visual BasicR. NET and Visual StudioR. NET Exam CramT 2 (Exam 70-306)
Developing and Implementing WindowsR-based Applications with Visual BasicR. NET and Visual StudioR. NET Exam CramT 2 (Exam 70-306)
ISBN: N/A
EAN: N/A
Year: 2002
Pages: 188

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net