Button.DialogResult 속성

정의

단추를 클릭할 때 부모 폼에 반환되는 값을 가져오거나 설정합니다.

public:
 virtual property System::Windows::Forms::DialogResult DialogResult { System::Windows::Forms::DialogResult get(); void set(System::Windows::Forms::DialogResult value); };
public virtual System.Windows.Forms.DialogResult DialogResult { get; set; }
member this.DialogResult : System.Windows.Forms.DialogResult with get, set
Public Overridable Property DialogResult As DialogResult

속성 값

DialogResult

DialogResult 값 중 하나입니다. 기본값은 None입니다.

구현

예외

할당된 값이 DialogResult 값 중 하나가 아닌 경우

예제

다음 코드 예제에서는 만들고 Button해당 DialogResult 속성을 설정 하 OK고에 추가 Form합니다.

private:
   void InitializeMyButton()
   {
      // Create and initialize a Button.
      Button^ button1 = gcnew Button;
      
      // Set the button to return a value of OK when clicked.
      button1->DialogResult = ::DialogResult::OK;
      
      // Add the button to the form.
      Controls->Add( button1 );
   }
private void InitializeMyButton()
 {
    // Create and initialize a Button.
    Button button1 = new Button();
 
    // Set the button to return a value of OK when clicked.
    button1.DialogResult = DialogResult.OK;
 
    // Add the button to the form.
    Controls.Add(button1);
 }
Private Sub InitializeMyButton()
    ' Create and initialize a Button.
    Dim button1 As New Button()
    
    ' Set the button to return a value of OK when clicked.
    button1.DialogResult = DialogResult.OK
    
    ' Add the button to the form.
    Controls.Add(button1)
End Sub

설명

이 속성에 DialogResult 대 한 설정 된 경우 이외의 None다른 항목 및 부모 폼 메서드를 통해 ShowDialog 표시 된 경우 단추를 클릭 하 고 아무 이벤트도 연결 하지 않고 부모 폼을 닫습니다. 그런 다음 단추를 클릭하면 폼 DialogResult 의 속성이 단추의 속성으로 설정 DialogResult 됩니다.

예를 들어 "예/아니요/취소" 대화 상자를 만들려면 3개의 단추를 추가하고 해당 DialogResult 속성을 Yes a0 No/>로 설정하면 됩니다 Cancel.

적용 대상