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.v20.1.dll

Declaration

[DXCategory("Behavior")]
[DefaultValue(DialogResult.None)]
public DialogResult DialogResult { get; set; }
<DXCategory("Behavior")>
<DefaultValue(DialogResult.None)>
Public Property DialogResult As DialogResult

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;
    }
}

Implements

See Also