Button Constructor
.NET Framework 2.0
Initializes a new instance of the Button class.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)
Assembly: System.Windows.Forms (in system.windows.forms.dll)
By default the Button displays no caption. To specify the caption text, set the Text property.
The following code example creates a Button, sets its DialogResult property to the OK value of DialogResult, and adds it to a Form.
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 = 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
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.