NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

How to Handle User Input to Dialog Boxes

Dialog boxes are typically used to prompt the user for data that is then used by an application. The form displaying the dialog box processes that information. When you display a dialog box, it is important to know how it is closed, or its "result." For example, if the user clicks a Cancel button, the data entered by the user is disposed of rather than retained. You can use the Button.DialogResult or Form.DialogResult property to find out how a dialog box is closed.

From the form that displays the dialog box (known as the dialog box's parent form), you can use the value of the DialogResult property to determine if an OK button or a Cancel button is clicked. Based on the DialogResult returned, you decide whether you need to retrieve the dialog box's information. You can manually set the value of a dialog box's DialogResult property when you do not use Button controls on your dialog box but still want to return a DialogResult.

The DialogResult property can also handle the Click event and close the dialog box by default. For example, setting the DialogResult property for a Button to OK will close the dialog box when the user clicks the button. This feature allows you to avoid adding code to the control's Click event handler to close the dialog box. If you need to perform additional tasks in the Click event handler, you can write code to handle the event and the DialogResult property will nonetheless close the dialog box for you.

See Also

Dialog Boxes | Creating Dialog Boxes | Closing Dialog Boxes and Retaining User Input | Retrieving the Result for Dialog Boxes