[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Using a toolbar

Posted on 2004-10-22
4
Medium Priority
?
253 Views
Last Modified: 2012-05-05
Using the code below it don't work for each button I have in my toolbar.  How can I use each of the buttons for something diffrent line I did with the menuitems?

Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick

' Do something here

    End Sub
0
Comment
Question by:teamdad
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 1000 total points
ID: 12385487
You can determine which button was clicked using code like this:

    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
                MsgBox("First Button Clicked")

            Case 1
                MsgBox("Second Button Clicked")

            Case 2
                MsgBox("Third Button Clicked")

        End Select
    End Sub
0
 
LVL 8

Accepted Solution

by:
wguerram earned 1000 total points
ID: 12385771
Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
        Select Case e.Button.Tag
            Case "NewRecord"
                'Code to add new record

            Case "Save"
                'Code to save record
        End Select
    End Sub
0
 

Author Comment

by:teamdad
ID: 12385880

For some reason this only fires the first button but not the second or third.

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 "1"
                MsgBox("First Button Clicked")

            Case "2"
                MsgBox("Second Button Clicked")

            Case "3"
                MsgBox("Third Button Clicked")

        End Select
    End Sub
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 12387992
Take off the quotes.  This:

    Case "1"

should be:

    Case 1

and it should be zero indexed.

~IM
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question