Back to Devexpress

XtraForm.ShowDialog(IWin32Window) Method

windowsforms-devexpress-dot-xtraeditors-dot-xtraform-dot-showdialog-x28-system-dot-windows-dot-forms-dot-iwin32window-x29.md

latest7.4 KB
Original Source

XtraForm.ShowDialog(IWin32Window) Method

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

Namespace : DevExpress.XtraEditors

Assembly : DevExpress.Utils.v25.2.dll

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

Declaration

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

Parameters

NameTypeDescription
ownerIWin32Window

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

|

Returns

TypeDescription
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.

csharp
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();
}
vb
Private Sub ShowMyModalForm()
    Dim myModalForm As DevExpress.XtraEditors.XtraForm = New MyModalForm()
    Dim dialogResult As DialogResult
    dialogResult = myModalForm.ShowDialog(Me)
    If dialogResult = System.Windows.Forms.DialogResult.OK Then
        ' Perform required actions here if the dialog result is Ok.
    Else
        ' Perform default actions here.
    End If
    myModalForm.Dispose()
End Sub

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.

winforms-scheduler-create-appointments-on-reminder-alert/CS/ReminderCustomActions/Forms/MyAppointmentEditForm.cs#L74

csharp
DialogResult result = dlg.ShowDialog(this);
dlg.Dispose();

winforms-scheduler-print-appointments-using-reports/CS/PrintingViaReports/MyAppointmentEditForm.cs#L103

csharp
DialogResult result = dlg.ShowDialog(this);
dlg.Dispose();

how-to-export-cell-range-to-a-datatable/CS/ExportToDataTableExample/Form1.cs#L203

csharp
newForm.ShowDialog(this);
return newForm;

reporting-crosstab-customization/CS/CrosstabControlCustomizationExample/Form1.cs#L38

csharp
}
form.ShowDialog(this);

reporting-winforms-custom-report-storage/CS/Form1.cs#L21

csharp
form.OpenReport(url);
form.ShowDialog(this);

winforms-scheduler-create-appointments-on-reminder-alert/VB/ReminderCustomActions/Forms/MyAppointmentEditForm.vb#L84

vb
Dim result As DialogResult = dlg.ShowDialog(Me)
dlg.Dispose()

winforms-scheduler-print-appointments-using-reports/VB/PrintingViaReports/MyAppointmentEditForm.vb#L111

vb
Dim result As DialogResult = dlg.ShowDialog(Me)
dlg.Dispose()

how-to-export-cell-range-to-a-datatable/VB/ExportToDataTableExample/Form1.vb#L188

vb
CType(grid.FocusedView, DevExpress.XtraGrid.Views.Grid.GridView).OptionsView.ShowGroupPanel = False
newForm.ShowDialog(Me)
Return newForm

reporting-crosstab-customization/VB/CrossTabControlCustomizationExample/Form1.vb#L38

vb
End If
form.ShowDialog(Me)

reporting-winforms-custom-report-storage/VB/Form1.vb#L24

vb
End If
form.ShowDialog(Me)

See Also

XtraForm Class

XtraForm Members

DevExpress.XtraEditors Namespace