DialogResult Enum
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Menentukan pengidentifikasi untuk menunjukkan nilai pengembalian kotak dialog.
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
- Warisan
- Atribut
Bidang
| Nama | Nilai | Deskripsi |
|---|---|---|
| None | 0 |
|
| OK | 1 | Nilai pengembalian kotak dialog adalah |
| Cancel | 2 | Nilai pengembalian kotak dialog adalah |
| Abort | 3 | Nilai pengembalian kotak dialog adalah |
| Retry | 4 | Nilai pengembalian kotak dialog adalah |
| Ignore | 5 | Nilai pengembalian kotak dialog adalah |
| Yes | 6 | Nilai pengembalian kotak dialog adalah |
| No | 7 | Nilai pengembalian kotak dialog adalah |
| TryAgain | 10 | Nilai pengembalian kotak dialog adalah Coba Lagi (biasanya dikirim dari tombol berlabel Coba Lagi). |
| Continue | 11 | Nilai pengembalian kotak dialog adalah Lanjutkan (biasanya dikirim dari tombol berlabel Lanjutkan). |
Contoh
Contoh kode berikut menunjukkan cara menampilkan dengan opsi yang MessageBox didukung oleh kelebihan beban ini .Show Setelah memverifikasi bahwa variabel string, ServerName, kosong, contoh menampilkan MessageBox, menawarkan opsi kepada pengguna untuk membatalkan operasi.
Show Jika nilai pengembalian metode dievaluasi ke Ya, formulir yang menampilkan MessageBox ditutup.
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
Keterangan
Properti Button.DialogResult dan Form.ShowDialog metode menggunakan enumerasi ini.