The CheckBox control
- Details
- Written by David Corrales
- Last Updated: 15 June 2016
- Created: 29 June 2011
- Hits: 29799
CheckBox Control [System.Windows.Forms.CheckBox]
Represents a Windows check box control.
Default Event: CheckedChanged
Why use the CheckBox control?
Use the CheckBox control to retrieve or display True / False values.
Important Properties:
Checked
Indicates whether the checkbox is in the checked state.
Values (Default: False):
True
False
Set the Checked property in the editor:
$checkbox1.Checked =$true
CheckAlign
Determines the location of the checkbox inside the control.
Why use the CheckAlign property?
Use the CheckAlign property when you want to change the location of the check box in respect to the control’s space.
Values (Default: MiddleLeft):
TopLeft
Content is vertically aligned at the top and horizontally aligned on the left.
TopCenter
Content is vertically aligned at the top and horizontally aligned at the center.
TopRight
Content is vertically aligned at the top and horizontally aligned on the right.
MiddleLeft
Content is vertically aligned in the middle and horizontally aligned on the left.
MiddleCenter
Content is vertically aligned in the middle and horizontally aligned at the center.
MiddleRight
Content is vertically aligned in the middle and horizontally aligned on the right.
BottomLeft
Content is vertically aligned at the bottom and horizontally aligned on the left.
BottomCenter
Content is vertically aligned at the bottom and horizontally aligned at the center.
BottomRight
Content is vertically aligned at the bottom and horizontally aligned on the right.
TextAlign
The alignment of the text that will be displayed on the control.
Values (Default: MiddleLeft):
Shares the same values as CheckAlign property.
Important Events:
CheckedChanged
Occurs whenever the Check property is changed.
Why use the CheckedChanged event?
Use the CheckedChanged event when you wish to respond to when a user changes the check box state by modifying the form controls or running a script . For example, you may wish to disable certain controls depending on the checkbox’s current value.
In this example, the event script disables the input textboxes for UserName and Password when the “Use Alternate Credentials” checkbox is unchecked.
$checkboxUseAltCred_CheckedChanged={ #Enable or Disable the TextBox controls $textboxUserName.Enabled = $checkboxUseAltCred.Checked $textboxPassword.Enabled = $checkboxUseAltCred.Checked }
When the checkbox is unchecked, the textboxes are disabled:
When the checkbox is checked, the textboxes are enabled:
For licensed customers, use the forum associated with your product in our Product Support Forums for Registered Customers.
For users of trial versions, please post in our Former and Future Customers - Questions forum.