Obtiene o establece un valor que se devuelve al formulario principal cuando se hace clic en el botón.
Espacio de nombres: System.Windows.Forms
Ensamblado: System.Windows.Forms (en system.windows.forms.dll)
Visual Basic (Declaración)
Public Overridable Property DialogResult As DialogResult
Dim instance As Button
Dim value As DialogResult
value = instance.DialogResult
instance.DialogResult = value
public virtual DialogResult DialogResult { get; set; }
public:
virtual property DialogResult DialogResult {
DialogResult get ();
void set (DialogResult value);
}
/** @property */
public DialogResult get_DialogResult ()
/** @property */
public void set_DialogResult (DialogResult value)
public function get DialogResult () : DialogResult
public function set DialogResult (value : DialogResult)
Valor de propiedad
Uno de los valores de DialogResult. El valor predeterminado es None.
Si la enumeración DialogResult de esta propiedad se establece en un valor distinto de None y el formulario principal se ha mostrado a través del método ShowDialog, al hacer clic en el botón se cierra el formulario principal sin necesidad de enlazar ningún evento. La propiedad DialogResult del formulario se establece a continuación en la propiedad DialogResult del botón cuando se hace clic en él.
Por ejemplo, para crear un cuadro de diálogo "Yes/No/Cancel", basta con agregar tres botones y establecer sus propiedades de DialogResult en Yes, No y Cancel.
En el ejemplo siguiente se crea un control Button, se establece su propiedad DialogResult en OK y se agrega a un objeto Form.
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 'InitializeMyButton
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:
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.set_DialogResult(get_DialogResult().OK);
// Add the button to the form.
get_Controls().Add(button1);
} //InitializeMyButton
private function InitializeMyButton()
{
// Create and initialize a Button.
var button1 : Button = new Button();
// Set the button to return a value of OK when clicked.
button1.DialogResult = System.Windows.Forms.DialogResult.OK;
// Add the button to the form.
Controls.Add(button1);
}
Windows 98, Windows 2000 Service Pack 4, Windows CE, Windows Millennium, Windows Mobile para Pocket PC, Windows Server 2003, Windows XP Media Center, Windows XP Professional x64, Windows XP SP2, Windows XP Starter
Microsoft .NET Framework 3.0 es compatible con Windows Vista, Microsoft Windows XP SP2 y Windows Server 2003 SP1.
.NET Framework
Compatible con: 3.0, 2.0, 1.1, 1.0
.NET Compact Framework
Compatible con: 2.0, 1.0