Occurs when the user clicks on a Button object in a Toolbar control.
Syntax
Private Sub object_ButtonClick(ByVal button As Button)
The ButtonClick event syntax has these parts:
Part | Description |
object | An object expression that evaluates to a Toolbar control. |
button | A reference to the clicked Button object. |
Remarks
To program an individual Button object's response to the ButtonClick event, use the value of the button argument. For example, the following code uses the Key property of the Button object to determine the appropriate action.
Private Sub Toolbar1_ButtonClick(ByVal Button As Button)
Select Case Button.Key
Case "Open"
CommonDialog1.ShowOpen
Case "Save"
CommonDialog1.ShowSave
End Select
End Sub
Note Because the user can rearrange Button objects using the Customize Toolbar dialog box, the value of the Index property may not always indicate the position of the button. Therefore, it's preferable to use the value of the Key property to retrieve a Button object.