DialogResult Enumeration
Specifies identifiers to indicate the return value of a dialog box.
[Visual Basic] <Serializable> <ComVisible(True)> Public Enum DialogResult [C#] [Serializable] [ComVisible(true)] public enum DialogResult [C++] [Serializable] [ComVisible(true)] __value public enum DialogResult [JScript] public Serializable ComVisible(true) enum DialogResult
Remarks
The Button.DialogResult property and the Form.ShowDialog method use this enumeration.
Members
| Member name | Description |
|---|---|
| Abort Supported by the .NET Compact Framework. | The dialog box return value is Abort (usually sent from a button labeled Abort). |
| Cancel Supported by the .NET Compact Framework. | The dialog box return value is Cancel (usually sent from a button labeled Cancel). |
| Ignore Supported by the .NET Compact Framework. | The dialog box return value is Ignore (usually sent from a button labeled Ignore). |
| No Supported by the .NET Compact Framework. | The dialog box return value is No (usually sent from a button labeled No). |
| None Supported by the .NET Compact Framework. | Nothing is returned from the dialog box. This means that the modal dialog continues running. |
| OK Supported by the .NET Compact Framework. | The dialog box return value is OK (usually sent from a button labeled OK). |
| Retry Supported by the .NET Compact Framework. | The dialog box return value is Retry (usually sent from a button labeled Retry). |
| Yes Supported by the .NET Compact Framework. | The dialog box return value is Yes (usually sent from a button labeled Yes). |
Example
[Visual Basic] Private Sub ValidateUserEntry5() ' Checks the value of the text. If ServerName.Text.Length = 0 Then ' Initializes variables to pass to the MessageBox.Show method. Dim Message As String = "You did not enter a server name. Cancel this operation?" Dim Caption As String = "No Server Name Specified" Dim Buttons As Integer = MessageBoxButtons.YesNo Dim Result As DialogResult 'Displays a MessageBox using the Question icon and specifying the No button as the default. Result = MessageBox.Show(Me, Message, Caption, MessageBoxButtons.YesNo) ' Gets the result of the MessageBox display. If Result = DialogResult.Yes Then ' Closes the parent form. Me.Close() End If End If End Sub [C#] private void validateUserEntry5() { // Checks the value of the text. if(serverName.Text.Length == 0) { // Initializes the variables to pass to the MessageBox.Show method. string message = "You did not enter a server name. Cancel this operation?"; string caption = "No Server Name Specified"; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result; // Displays the MessageBox. result = MessageBox.Show(this, message, caption, buttons); if(result == DialogResult.Yes) { // Closes the parent form. this.Close(); } } } [C++] private: void validateUserEntry5() { // Checks the value of the text. if (serverName->Text->Length == 0) { // Initializes the variables to pass to the MessageBox::Show method. String* message = S"You did not enter a server name. Cancel this operation?"; String* caption = S"No Server Name Specified"; MessageBoxButtons buttons = MessageBoxButtons::YesNo; System::Windows::Forms::DialogResult result; // Displays the MessageBox. result = MessageBox::Show(this, message, caption, buttons); if (result == DialogResult::Yes) { // Closes the parent form. this->Close(); } } }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Namespace: System.Windows.Forms
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)