Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Toolbar Problem

Posted on 2004-08-16
5
Medium Priority
?
234 Views
Last Modified: 2010-04-23
how to i add events to toolbar buttons, i cant work out how to get the toolbar buttons to work
0
Comment
Question by:davidrichardson
[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
5 Comments
 
LVL 4

Expert Comment

by:srcalc
ID: 11817374
   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.
0
 
LVL 7

Author Comment

by:davidrichardson
ID: 11819156
That gives me the same event on all the buttons, how do I specify each button
0
 
LVL 4

Accepted Solution

by:
Daniellus83 earned 500 total points
ID: 11819455
I know this problem:


try this:

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


You wil see you have to extract this information from the second argument (ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs)
So if you use this code (I have a toolbar with 3 buttons; named button1,button2,button3) it will work:

    Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
        If e.Button.Text = "Button1" Then
            MsgBox("You clicked button 1...")
        ElseIf e.Button.Text = "Button2" Then
            MsgBox("You clicked button 2...")
        ElseIf e.Button.Text = "Button3" Then
            MsgBox("You clicked button 3...")
        End If
    End Sub

Try it and maybe you like it!

Daniël
0
 
LVL 1

Expert Comment

by:Trancedified
ID: 11855900
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
0
 
LVL 7

Author Comment

by:davidrichardson
ID: 11856846
sorry i thought i closed this question
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

721 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