The WinCheckBox class represents an extensible and themable checkbox control for Windows Forms which supports both Windows XP and classic Windows themes and can adapt to the current Windows theme.
In addition to supporting the default check and unchecked states, the WinCheckBox control also supports the Indeterminate check state. By default, the WinCheckBox will either be checked or unchecked if its checkbox portion is clicked. In order to enable the Indeterminate check state, the ThreeState property must be set to true. The Indeterminate check state will then be available when the checkbox portion of the WinCheckBox is clicked in rotation with the Checked and Unchecked states.
To know what state the WinCheckBox is in, you can either consult the Checked property if ThreeState is set to false or the CheckState property if ThreeState is set to true. If the ThreeState property is set to true, the Checked property will return true for both the Checked and Indeterminate check states.
VB.NET |
Copy Code |
---|---|
Dim checkbox As New WinCheckBox( "Value selected" ) checkbox.ThreeState = True checkbox.CheckState = CheckState.Indeterminate checkBox.Location = New Point( 10, 10 ) Me.Controls.Add( checkBox ) |
C# |
Copy Code |
---|---|
WinCheckBox checkbox = new WinCheckBox( "Value selected" ); checkbox.ThreeState = true; checkbox.CheckState = CheckState.Indeterminate; checkBox.Location = new Point( 10, 10 ); this.Controls.Add( checkBox ); |
The alignment of the WinCheckBox control's checkbox is determined by the CheckAlign property while its text alignment is determined by the TextAlign property. By default, both the CheckAlign and TextAlign properties are set to ContentAlignment.MiddleLeft resulting in the "standard" checkbox appearance.
Both the checkbox and the text of the WinCheckBox control can be set to any one of the 9 content alignment positions. For example, in code below, the alignment of the checkbox was set to ContentAlignment.TopCenter while the alignment of the text was set to ContentAlignment.BottomCenter.
VB.NET |
Copy Code |
---|---|
Dim check As New WinCheckBox( "Hello World", CheckState.Checked ) check.CheckAlign = ContentAlignment.TopCenter check.TextAlign = ContentAlignment.BottomCenter check.Height = 40 check.Location = New Point( 10, 10 ) Me.Controls.Add( check ) |
C# |
Copy Code |
---|---|
WinCheckBox check = new WinCheckBox( "Hello World", CheckState.Checked ); check.CheckAlign = ContentAlignment.TopCenter; check.TextAlign = ContentAlignment.BottomCenter; check.Height = 40; check.Location = new Point( 10, 10 ); this.Controls.Add( check ); |