windowsforms-devexpress-dot-xtraeditors-dot-basebutton-f3a976e9.md
Gets or sets a value that is returned to the parent form when the button is clicked.
Namespace : DevExpress.XtraEditors
Assembly : DevExpress.XtraEditors.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
[DefaultValue(DialogResult.None)]
[DXCategory("Behavior")]
public DialogResult DialogResult { get; set; }
<DXCategory("Behavior")>
<DefaultValue(DialogResult.None)>
Public Property DialogResult As DialogResult
| Type | Default | Description |
|---|---|---|
| DialogResult | None |
A DialogResult enumeration member specifying the value that is returned to the parent form when the button is clicked.
|
You can place SimpleButtons onto a form, and show it with the ShowDialog method. If a button DialogResult property is set to anything other than DialogResult.None , a click on this button closes the form and assigns the button’s DialogResult value to the form’s DialogResult property.
The following code shows a form with three buttons - OK, Retry, and Cancel. Any of these buttons closes the form and returns its corresponding DialogResult.
//XtraForm1 has three simple buttons with the following settings
this.simpleButton1.DialogResult = System.Windows.Forms.DialogResult.OK;
this.simpleButton1.Text = "OK";
this.simpleButton2.DialogResult = System.Windows.Forms.DialogResult.Retry;
this.simpleButton2.Text = "Retry";
this.simpleButton3.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.simpleButton3.Text = "Cancel";
using(var dialog = new XtraForm1()) {
//immediatelly check the result
DialogResult result = dialog.ShowDialog();
switch(result) {
case DialogResult.Cancel:
//action #1
break;
case DialogResult.OK:
//action #2
break;
case DialogResult.Retry:
//action #3
break;
}
//check the result later - the DialogResult of a clicked button
//is stored in the form's DialogResult property
switch(dialog.DialogResult) {
case DialogResult.Cancel:
//action #1
break;
case DialogResult.OK:
//action #2
break;
case DialogResult.Retry:
//action #3
break;
}
}
'XtraForm1 has three simple buttons with the following settings
Me.simpleButton1.DialogResult = System.Windows.Forms.DialogResult.OK
Me.simpleButton1.Text = "OK"
Me.simpleButton2.DialogResult = System.Windows.Forms.DialogResult.Retry
Me.simpleButton2.Text = "Retry"
Me.simpleButton3.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.simpleButton3.Text = "Cancel"
Using dialog = New XtraForm1()
'immediatelly check the result
Dim result As DialogResult = dialog.ShowDialog()
Select Case result
Case DialogResult.Cancel
'action #1
Case DialogResult.OK
'action #2
Case DialogResult.Retry
'action #3
End Select
'check the result later - the DialogResult of a clicked button
'is stored in the form's DialogResult property
Select Case dialog.DialogResult
Case DialogResult.Cancel
'action #1
Case DialogResult.OK
'action #2
Case DialogResult.Retry
'action #3
End Select
End Using
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the DialogResult property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
buttonOk.Text = "OK";
buttonOk.DialogResult = DialogResult.OK;
buttonOk.Click += (sender1, e1) => {
buttonOk.Text = "OK"
buttonOk.DialogResult = DialogResult.OK
AddHandler buttonOk.Click, Sub(sender1, e1)
See Also