Skip to main content

XtraForm.ShowDialog(IWin32Window) Method

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

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.Utils.v24.1.dll

NuGet Packages: DevExpress.Utils, DevExpress.Wpf.Core

Declaration

public DialogResult ShowDialog(
    IWin32Window owner
)

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

The following code snippets (auto-collected from DevExpress Examples) contain references to the ShowDialog(IWin32Window) method.

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.

See Also