Several built-in dialogue boxes may be used in Windows forms to do various activities such as opening and saving files, printing a page, providing colour, font, and page setting options to an application's user, and so on. These built-in dialogue windows save the developer time and effort.
First, let us update read execute commands and retrieve data, store and connect dialogue box control classes derive from the CommonDialog class and override the base class's RunDialog() function to construct the appropriate dialogue box.
On calling the ShowDialog() function by the user of the dialogue box, the RunDialog() function is automatically invoked.
At runtime, the ShowDialog method is used to display all of the dialogue box controls. It returns a value of the DialogResult enumeration type. The values of the DialogResult enumeration are as follows:
- Abort − returns DialogResult.Abort value, on clicking on Abort button.
- Cancel − returns DialogResult.Cancel, on clicking on a Cancel button.
- Ignore − returns DialogResult.Ignore on clicking on the 'Ignore' button.
- No − returns DialogResult.No, on clicking on a No button.
- None − returns nothing, dialogue box continues running.
- OK − returns DialogResult.OK, on clicking on the OK button
- Retry − returns DialogResult.Retryby, on clicking on the Retry button
- Yes − returns DialogResult.Yes, on clicking on the Yes button
Common dialog class inheritance is as shown below−
All these classes mentioned above have corresponding controls that could be added from the Toolbox during design time. You can include relevant functionality of these classes to your application, either by instantiating the class programmatically or by using appropriate controls.
When you double-click any of the dialogue controls in the toolbox or drag the control onto the form, it appears in the Component tray at the bottom of the Windows Forms Designer; first, let us do not directly show up on the form.
The commonly used dialog box controls are ColorDialog, FontDialog, OpenFileDialog, SaveFileDialog, PrintDialog