Link to home
Start Free TrialLog in
Avatar of davidrichardson
davidrichardson

asked on

Toolbar Problem

how to i add events to toolbar buttons, i cant work out how to get the toolbar buttons to work
Avatar of srcalc
srcalc

   Private Sub ToolBar_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar.ButtonClick
        MsgBox(e.Button)
    End Sub

This will pop up a message box telling the button text that was clicked.
Avatar of davidrichardson

ASKER

That gives me the same event on all the buttons, how do I specify each button
ASKER CERTIFIED SOLUTION
Avatar of Daniellus83
Daniellus83
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello,

This references the index of each button in the toolbar that you made:

Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
        Select Case ToolBar1.Buttons.IndexOf(e.Button)
            Case 0
                 'skip this one
            Case 1
                'code for 1st button
            Case 2
                'More code here for other buttons
            Case 3 'etc etc
        End Select
    End Sub

Good luck

Chris
sorry i thought i closed this question