DialogResult Перечисление
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Указывает идентификаторы, указывающие возвращаемое значение диалогового окна.
public enum class DialogResult
[System.Runtime.InteropServices.ComVisible(true)]
public enum DialogResult
public enum DialogResult
[<System.Runtime.InteropServices.ComVisible(true)>]
type DialogResult =
type DialogResult =
Public Enum DialogResult
- Наследование
- Атрибуты
Поля
| Имя | Значение | Описание |
|---|---|---|
| None | 0 |
|
| OK | 1 | Возвращаемое значение диалогового окна (обычно отправляется |
| Cancel | 2 | Возвращаемое значение диалогового окна (обычно отправляется |
| Abort | 3 | Возвращаемое значение диалогового окна (обычно отправляется |
| Retry | 4 | Возвращаемое значение диалогового окна (обычно отправляется |
| Ignore | 5 | Возвращаемое значение диалогового окна (обычно отправляется |
| Yes | 6 | Возвращаемое значение диалогового окна (обычно отправляется |
| No | 7 | Возвращаемое значение диалогового окна (обычно отправляется |
| TryAgain | 10 | Возвращаемое диалоговое окно — "Повторить попытку" (обычно отправляется из кнопки с меткой "Повторить попытку"). |
| Continue | 11 | Возвращаемое значение диалогового окна — "Продолжить" (обычно отправляется из кнопки "Продолжить"). |
Примеры
В следующем примере кода показано, как отобразить MessageBox параметры, поддерживаемые этой перегрузкой Show. После проверки того, ServerNameчто строковая переменная пуста, в примере отображается MessageBoxпредложение пользователю отменить операцию.
Show Если возвращаемое значение метода оценивается как "Да", форма, отображаемая в MessageBox ней, закрыта.
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;
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();
}
}
}
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();
}
}
}
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 = System.Windows.Forms.DialogResult.Yes Then
' Closes the parent form.
Me.Close()
End If
End If
End Sub
Комментарии
Свойство Button.DialogResult и Form.ShowDialog метод используют это перечисление.