MessageBoxButtons 열거형

정의

MessageBox에 표시할 단추를 정의하는 상수를 지정합니다.

public enum class MessageBoxButtons
public enum MessageBoxButtons
type MessageBoxButtons = 
Public Enum MessageBoxButtons
상속
MessageBoxButtons

필드

AbortRetryIgnore 2

메시지 상자에 중단, 다시 시도 및 무시 단추가 있습니다

CancelTryContinue 6

메시지 상자에 취소, 다시 시도 및 계속 단추가 포함되도록 지정합니다.

OK 0

메시지 상자에 확인 단추가 있습니다.

OKCancel 1

메시지 상자에 확인 및 취소 단추가 있습니다.

RetryCancel 5

메시지 상자에 다시 시도 및 취소 단추가 있습니다.

YesNo 4

메시지 상자에 예 및 아니요 단추가 있습니다.

YesNoCancel 3

메시지 상자에 예, 아니요 및 취소 단추가 있습니다.

예제

다음 코드 예제를 사용 하는 방법을 보여 줍니다는 MessageBox 사용자 폼을 닫는 못하도록 영업 기회 수 있도록 합니다. 이 예제에서 메서드가 호출 되도록 하려면는 FormClosing 폼의 이벤트입니다.

private:
   void Form1_FormClosing(Object^ sender, FormClosingEventArgs^ e)
   {
      // If the no button was pressed ...
      if ((MessageBox::Show(
         "Are you sure that you would like to close the form?", 
         "Form Closing", MessageBoxButtons::YesNo, 
         MessageBoxIcon::Question) == DialogResult::No))
      {
         // cancel the closure of the form.
         e->Cancel = true;
      }
   }
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
    const string message =
        "Are you sure that you would like to close the form?";
    const string caption = "Form Closing";
    var result = MessageBox.Show(message, caption,
                                 MessageBoxButtons.YesNo,
                                 MessageBoxIcon.Question);

    // If the no button was pressed ...
    if (result == DialogResult.No)
    {
        // cancel the closure of the form.
        e.Cancel = true;
    }
}
Private Sub Form1_FormClosing( _
    ByVal sender As System.Object, _
    ByVal e As System.Windows.Forms.FormClosingEventArgs) _
    Handles MyBase.FormClosing

    Dim message As String = _
            "Are you sure that you would like to close the form?"
    Dim caption As String = "Form Closing"
    Dim result = MessageBox.Show(message, caption, _
                                 MessageBoxButtons.YesNo, _
                                 MessageBoxIcon.Question)

    ' If the no button was pressed ...
    If (result = DialogResult.No) Then
        ' cancel the closure of the form.
        e.Cancel = True
    End If
End Sub

설명

이 열거는 MessageBox 클래스에서 사용됩니다.

적용 대상

추가 정보