Aracılığıyla paylaş


Button.DialogResult Özellik

Tanım

Düğmeye tıklandığında üst forma döndürülen bir 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

Değerlerden DialogResult biri. Varsayılan değer None değeridir.

Uygulamalar

Özel durumlar

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

Örnekler

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

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

Bu özelliğin DialogResult değeri dışında Nonebir değere ayarlanmış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 değerine ayarlanır DialogResult .

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

Şunlara uygulanır