DialogResult Enumeration
.NET Framework 2.0
Specifies identifiers to indicate the return value of a dialog box.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)
Assembly: System.Windows.Forms (in system.windows.forms.dll)
| Member name | Description | |
|---|---|---|
![]() | Abort | The dialog box return value is Abort (usually sent from a button labeled Abort). |
![]() | Cancel | The dialog box return value is Cancel (usually sent from a button labeled Cancel). |
![]() | Ignore | The dialog box return value is Ignore (usually sent from a button labeled Ignore). |
![]() | No | The dialog box return value is No (usually sent from a button labeled No). |
![]() | None | Nothing is returned from the dialog box. This means that the modal dialog continues running. |
![]() | OK | The dialog box return value is OK (usually sent from a button labeled OK). |
![]() | Retry | The dialog box return value is Retry (usually sent from a button labeled Retry). |
![]() | Yes | The dialog box return value is Yes (usually sent from a button labeled Yes). |
The Button.DialogResult property and the Form.ShowDialog method use this enumeration.
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
private void ValidateUserEntry5()
{
// Checks the value of the text.
if (serverName.get_Text().get_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.Equals(DialogResult.Yes)) {
// Closes the parent form.
this.Close();
}
}
} //ValidateUserEntry5
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
Community Additions
ADD
Show:
