BaseButton.DialogResult Property
Gets or sets a value that is returned to the parent form when the button is clicked.
Namespace: DevExpress.XtraEditors
Assembly: DevExpress.XtraEditors.v24.1.dll
NuGet Package: DevExpress.Win.Navigation
Declaration
[DefaultValue(DialogResult.None)]
[DXCategory("Behavior")]
public DialogResult DialogResult { get; set; }
Property Value
Type | Default | Description |
---|---|---|
DialogResult | None | A DialogResult enumeration member specifying the value that is returned to the parent form when the button is clicked. |
Remarks
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;
}
}
Related GitHub Examples
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.