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!

Button.DialogResult

Gets or sets a value that is returned to the parent form when the button is clicked.

[Visual Basic]
Overridable Public Property DialogResult As DialogResult
[C#]
public DialogResult DialogResult {virtual get; virtual set;}
[C++]
public: __property virtual DialogResult get_DialogResult();
public: __property virtual void set_DialogResult(DialogResult);
[JScript]
public function get DialogResult() : DialogResult;
public function set DialogResult(DialogResult);

Property Value

One of the DialogResult values. The default value is None.

Exceptions

Exception Type Condition
InvalidEnumArgumentException The value assigned is not one of the DialogResult values.

Remarks

If the value of this property is set to anything other than None, and if the parent form was displayed through the ShowDialog method, clicking the button closes the parent form without you having to hook up any events. The form's DialogResult property is then set to the DialogResult of the button when the button is clicked.

For example, to create a "Yes/No/Cancel" dialog, simply add three buttons and set their DialogResult properties to Yes, No, and Cancel.

Example [Visual Basic]

The following example instantiates a Button and sets its DialogResult property to DialogResult.Ok.

[Visual Basic]

' Instantiate a Button.
Private Button1 As System.WinForms.Button
Private MySub()
   ' Initialize a new Button.
   Form1.Button1 = New System.WinForms.Button
 
  ' Set the button to return a value of Ok when clicked.
   Button1.DialogResult = DialogResult.Ok

   ' Add the button to the form.
   Form1.Controls.Add(Button1)
End Sub

See Also

Button Class | Button Members | System.WinForms Namespace