Occurs when a ListBox control Style property is set to 1 (checkboxes) and an item’s checkbox in the ListBox control is selected or cleared.
Syntax
Private Sub object_ItemCheck([index As Integer])
The ItemCheck event syntax has these parts:
Part | Description |
object | An object expression that evaluates to an object in the Applies To list. |
index | An integer that uniquely identifies the item in the listbox which was clicked. |
Remarks
Note The ItemCheck event does not occur when a list item is only highlighted; rather, it occurs when the check box of the list item is selected or cleared.
The ItemCheck event can also occur programmatically whenever an element in Selected array of the ListBox is changed (and its Style property is set to 1.)
The ItemCheck event occurs before the Click event.
Attempting to unload a form using Unload Me in a ListBox control's ItemCheck event causes a General Protection Fault (GPF). For example:
Private Sub Form_Load()
Dim i%
For i = 0 To 20
List1.AddItem i
Next i
End Sub
Private Sub List1_ItemCheck(Item As Integer)
Unload Me
End Sub
This example also produces a GPF if the spacebar is pressed, or if you attempt to select an item in the ListBox using a CommandButton.
The recommended procedure for unloading a form is to add the Unload statement to the Click event in a CommandButton or Menu control.