Occurs when the user presses and then releases a mouse button over an object. It can also occur when the value of a control is changed.
For a Form object, this event occurs when the user clicks either a blank area or a disabled control. For a control, this event occurs when the user:
You can also trigger the Click event in code by:
Private Sub Form_Click( )
Private Sub object_Click([index])
Part | Description |
---|---|
object | An object expression that evaluates to an object. |
index | An integer that uniquely identifies a control. |
Typically, you attach a Click event procedure to a CommandButton control, Menu object, or a PictureBox control to carry out commands and command-like actions. For the other applicable controls, use this event to trigger actions in response to a change in the control.
You can use a control's Value property to test the state of the control from code. Clicking a control generates MouseDown and MouseUp events in addition to the Click event. The order in which these three events occur varies from control to control.
For example, for ListBox and CommandButton controls, the events occur in this order:
MouseDown, Click, MouseUp.
But for Label, or PictureBox controls, the events occur in this order:
MouseDown, MouseUp, Click.
When you are attaching event procedures for these related events, be sure that their actions do not conflict. If the order of events is important in your application, test the control to determine the event order.
If there is code in the Click event, the DlbClick event will never trigger, because the Click event is the first event to trigger between the two. As a result, the mouse click is intercepted by the Click event, so the DblClick event does not occur.