Button.DialogResult Özellik

Tanım

Düğmeye tıklandığında üst forma döndürülen değeri alır veya ayarlar.

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

Özellik Değeri

DialogResult

Değerlerden DialogResult biri. None varsayılan değerdir.

Uygulamalar

Özel durumlar

Atanan değer değerlerden DialogResult biri değil.

Örnekler

Aşağıdaki kod örneği bir Buttonoluşturur, özelliğini olarak OKayarlar DialogResult ve bir Formöğesine ekler.

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

Açıklamalar

DialogResult Bu özellik için dışında bir değere Noneayarlanmışsa ve üst form yöntemiyle ShowDialog görüntüleniyorsa, düğmeye tıklandığında herhangi bir olay bağlamanıza gerek kalmadan üst form kapatılır. Ardından, düğme tıklatıldığında formun DialogResult özelliği düğmenin özelliğine ayarlanır DialogResult .

Örneğin, "Evet/Hayır/İptal" iletişim kutusu oluşturmak için üç düğme eklemeniz ve özelliklerini DialogResult Yes, Nove Cancelolarak ayarlamanız yeterlidir.

Şunlara uygulanır