CheckBox Control (VBCCRCheckBox)
The VBCCRCheckBox control is a checkbox control that allows users to select multiple options from a group. It supports three states (checked, unchecked, and grayed/partially checked).
Properties
Appearance Properties
Alignment
- Text alignmentvbLeftJustify
(0) - Left alignmentvbRightJustify
(1) - Right alignment
Appearance
- Visual stylecc2D
(0) - 2D appearancecc3D
(1) - 3D appearance
BackColor
- Background colorForeColor
- Text colorFont
- Font propertiesCaption
- Checkbox textPicture
- IconDisabledPicture
- Icon for disabled stateDownPicture
- Icon for pressed stateEnabled
- Whether the control is enabledVisible
- Whether the control is visibleValue
- Check statevbUnchecked
(0) - UncheckedvbChecked
(1) - CheckedvbGrayed
(2) - Grayed (partially checked)
ToolTipText
- Tooltip text
Events
Click
- Triggered when clickedDblClick
- Triggered when double-clickedMouseDown
- Triggered when mouse button is pressedMouseMove
- Triggered when mouse movesMouseUp
- Triggered when mouse button is releasedGotFocus
- Triggered when control receives focusLostFocus
- Triggered when control loses focusKeyDown
- Triggered when key is pressed downKeyPress
- Triggered when key is pressedKeyUp
- Triggered when key is released
Code Examples
Basic Usage
vb
Private Sub InitCheckBox()
With Check1
.Caption = "Enable Option"
.Value = vbUnchecked ' Default unchecked
.ToolTipText = "Check to enable this option"
End With
End Sub
Option Group Management
vb
Private Type CheckGroup
Name As String
Boxes() As VBCCRCheckBox
Count As Long
MinSelected As Long
MaxSelected As Long
End Type
Private Type GroupManager
Groups() As CheckGroup
Count As Long
End Type
Private Groups As GroupManager
Private Sub InitGroupManager()
ReDim Groups.Groups(1 To 10)
Groups.Count = 0
End Sub
Private Function CreateCheckGroup(ByVal Name As String, _
Optional ByVal MinSelected As Long = 0, _
Optional ByVal MaxSelected As Long = -1) _
As Long
With Groups
.Count = .Count + 1
If .Count > UBound(.Groups) Then
ReDim Preserve .Groups(1 To .Count + 10)
End If
With .Groups(.Count)
.Name = Name
ReDim .Boxes(1 To 10)
.Count = 0
.MinSelected = MinSelected
.MaxSelected = MaxSelected
End With
CreateCheckGroup = .Count
End With
End Function