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
DialogResult property to be set to DialogResult.Cancel. Unlike non-modal forms, the
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
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
Dispose method of the form when the form is no longer needed by your application.
Partager