XtraForm.ShowDialog(IWin32Window) Method

Shows the form as a modal dialog box with the specified owner.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.Utils.v20.1.dll

Declaration

public DialogResult ShowDialog(
    IWin32Window owner
)
Public Function ShowDialog(
    owner As IWin32Window
) As DialogResult

Parameters

Name Type Description
owner IWin32Window

Any object implementing IWin32Window that represents the top-level window that will own the modal dialog box.

Returns

Type Description
DialogResult

One of the DialogResult values.

Remarks

Use this method to show a modal dialog window in your application. The owner parameter specifies the form that owns the modal dialog window being shown.

When the modal dialog window is closed, the ShowDialog method returns one of the DialogResult values. To specify the dialog result to be returned when the modal form is closed, use the form's DialogResult property, or the BaseButton.DialogResult property of a button on the form.

NOTE

Since modal windows are not automatically disposed, you must call the Dispose method manually if the modal window is no longer needed.

The code snippet below illustrates how to display a modal form for a given owner form, and read the dialog result.


private void ShowMyModalForm() {
    DevExpress.XtraEditors.XtraForm myModalForm = new MyModalForm();
    DialogResult dialogResult;
    dialogResult = myModalForm.ShowDialog(this);
    if (dialogResult == System.Windows.Forms.DialogResult.OK) {
        // Perform required actions here if the dialog result is Ok.
    }
    else {
        // Perform default actions here.
    }
    myModalForm.Dispose();
}
See Also