Export (0) Print
Expand All

CheckBox Constructor

Initializes a new instance of the CheckBox class.

[Visual Basic]
Public Sub New()
[C#]
public CheckBox();
[C++]
public: CheckBox();
[JScript]
public function CheckBox();

Remarks

By default, when a new CheckBox is instantiated, AutoCheck is set to true, Checked is set to false, and Appearance is set to Normal.

Example

The following example creates and initializes a CheckBox, gives it the appearance of a toggle button, sets AutoCheck to false, and adds it to a Form.

[Visual Basic] 
Public Sub InstantiateMyCheckBox()
    ' Create and initialize a CheckBox.   
    Dim checkBox1 As New CheckBox()
    
    ' Make the check box control appear as a toggle button.
    checkBox1.Appearance = Appearance.Button
    
    ' Turn off the update of the display on the click of the control.
    checkBox1.AutoCheck = False
    
    ' Add the check box control to the form.
    Controls.Add(checkBox1)
End Sub 'InstantiateMyCheckBox

[C#] 
public void InstantiateMyCheckBox()
 {
    // Create and initialize a CheckBox.   
    CheckBox checkBox1 = new CheckBox(); 
    
    // Make the check box control appear as a toggle button.
    checkBox1.Appearance = Appearance.Button;
 
    // Turn off the update of the display on the click of the control.
    checkBox1.AutoCheck = false;
 
    // Add the check box control to the form.
    Controls.Add(checkBox1);
 }
 

[C++] 
public:
    void InstantiateMyCheckBox() {
        // Create and initialize a CheckBox.   
        CheckBox __gc *checkBox1 = new CheckBox(); 
    
        // Make the check box control appear as a toggle button.
        checkBox1->Appearance = Appearance::Button;
 
        // Turn off the update of the display on the click of the control.
        checkBox1->AutoCheck = false;
 
        // Add the check box control to the form.
        this->Controls->Add(checkBox1);
    };
 

[JScript] 
public function InstantiateMyCheckBox()
 {
    // Create and initialize a CheckBox.   
    var checkBox1 : CheckBox = new CheckBox(); 
    
    // Make the check box control appear as a toggle button.
    checkBox1.Appearance = Appearance.Button;
 
    // Turn off the update of the display on the click of the control.
    checkBox1.AutoCheck = false;
 
    // Add the check box control to the form.
    Controls.Add(checkBox1);
 }
 

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

CheckBox Class | CheckBox Members | System.Windows.Forms Namespace | CheckBox

Show:
© 2014 Microsoft