The control inherits from GroupBox so it can easily contain other controls. It uses the WithEvents keyword to declare a CheckBox variable so it can easily catch that control's events.
The control's constructor creates and positions the CheckBox control.
The control's Text property saves the new text in the CheckBox control and resizes that control so it can display the text.
The CheckGroup control delegates its Checked property to its CheckBox.
Helper subroutine EnableDisableControls enables or disables the controls contained within the CheckGroup depending on whether the CheckBox is checked. It does not disable the CheckBox itself so the user can check it later.
When the CheckBox is checked or unchecked, the CheckedChanged event handler calls EnableDisableControls.
Finally the control's Layout event handler also calls EnableDisableControls. When the control is first loaded, the CheckBox's CheckedChanged event handler fires before any contained controls are loaded so that event's call to EnableDisableControls does not enable and disable them properly. The control calls EnableDisableControls again in the Layout event handler after all of the contained controls are loaded.
|