- owner
- Any object that implements System.Windows.Forms.IWin32Window that represents the top-level window that will own the modal dialog box.
One of the System.Windows.Forms.DialogResult values.
You can use this method to display a modal dialog box in your application. When this method is called, the code following it is not executed until after the dialog box is closed. The dialog box can be assigned one of the values of System.Windows.Forms.DialogResult by assigning it to the Button.DialogResult property of a System.Windows.Forms.Button on the form or by setting the Form.DialogResult property of the form in code. This value is then returned by this method. You can use this return value to determine how to process the actions that occurred in the dialog box. For example, if the dialog box was closed and returned the DialogResult.Cancel value through this method, you could prevent code following the call to Form.ShowDialog from executing.
When a form is displayed as a modal dialog box, clicking the Close button (the button with an X at the upper-right corner of the form) causes the form to be hidden and the Form.DialogResult property to be set to DialogResult.Cancel. Unlike modeless forms, the Form.Close method is not called by the .NET Framework when the user clicks the close form button of a dialog box or sets the value of the Form.DialogResult property. Instead the form is hidden and can be shown again without creating a new instance of the dialog box. Because a form displayed as a dialog box is hidden instead of closed, you must call the Control.Dispose(bool) method of the form when the form is no longer needed by your application.
This version of the Form.ShowDialog method allows you to specify a specific form that will own the dialog box that is shown.