DialogResult Enumeráció
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Egy párbeszédpanel visszatérési értékét jelző azonosítókat ad meg.
public enum class DialogResult
[System.Runtime.InteropServices.ComVisible(true)]
public enum DialogResult
[<System.Runtime.InteropServices.ComVisible(true)>]
type DialogResult =
Public Enum DialogResult
- Öröklődés
- Attribútumok
Mezők
| Name | Érték | Description |
|---|---|---|
| None | 0 |
|
| OK | 1 | A párbeszédpanel visszatérési |
| Cancel | 2 | A párbeszédpanel visszatérési értéke (általában |
| Abort | 3 | A párbeszédpanel visszatérési értéke (általában |
| Retry | 4 | A párbeszédpanel visszatérési |
| Ignore | 5 | A párbeszédpanel visszatérési értéke (általában |
| Yes | 6 | A párbeszédpanel visszatérési értéke (általában |
| No | 7 | A párbeszédpanel visszatérési |
Példák
Az alábbi példakód bemutatja, hogyan jeleníthet meg egy MessageBox olyan beállítást, amelyet a rendszer túlterhelése Showtámogat. Miután ellenőrizte, ServerNamehogy egy sztringváltozó üres-e, a példában megjelenik egy MessageBox, amely lehetőséget kínál a felhasználónak a művelet megszakítására. Ha a Show metódus visszatérési értéke Igen értékre van kiértékelve, az azt megjelenítő MessageBox űrlap bezárul.
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
Megjegyzések
A Button.DialogResult tulajdonság és a metódus ezt az Form.ShowDialog enumerálást használja.