Solved

Toolbar Problem

Posted on 2004-08-16
5
232 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 125 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
vb.net datagrid point 4 35
Web page design problem 3 41
FTP recursive download files 5 27
How to embed a manual into my vb 2005 project 7 26
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

739 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