MessageBoxDefaultButton 열거형

정의

MessageBox의 기본 단추를 정의하는 상수를 지정합니다.

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

필드

Button1 0

메시지 상자의 첫 번째 단추는 기본 단추입니다.

Button2 256

메시지 상자의 두 번째 단추는 기본 단추입니다.

Button3 512

메시지 상자의 세 번째 단추는 기본 단추입니다.

Button4 768

메시지 상자의 도움말 단추가 기본 단추가 되도록 지정합니다.

예제

다음 코드 예제에 표시 하는 방법을 보여 줍니다.는 MessageBox 의이 오버 로드에 의해 지원 되는 옵션을 사용 하 여 Show입니다. 있는지 확인 한 후 문자열 변수인 ServerName는 비어 있는 경우이 예제에서는 표시를 MessageBox 질문 상자 아이콘을 사용 하 여 제공 된 사용자 작업을 취소 하는 옵션입니다. 예제에서는 합니다 RightAlign 의 멤버는 MessageBoxOptions 열거형 대화 상자의 오른쪽 가장자리에 텍스트를 맞춥니다. 경우는 Show 메서드의 반환 값으로 계산 되 Yes, 표시는 양식은 MessageBox 닫혀 있습니다.

private:
   void validateUserEntry2()
   {
      // 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, MessageBoxIcon::Question, MessageBoxDefaultButton::Button1, MessageBoxOptions::RightAlign );
         if ( result == ::DialogResult::Yes )
         {
            // Closes the parent form.
            this->Close();
         }
      }
   }

private void validateUserEntry2()
{

    // 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,
            MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, 
            MessageBoxOptions.RightAlign);

        if(result == DialogResult.Yes)
        {

            // Closes the parent form.

            this.Close();
        }
    }
}
Private Sub ValidateUserEntry2()


    ' 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, _
            MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign)


        ' 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

설명

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

적용 대상