CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2006
    Posts
    22

    Smile Doubt about toolbar......

    Hi Every body


    I already add a toolbar in MDI form. In toolbar button collection i add buttons but now i cann't identify which button i clicked.


    Pls help me..

    By Rajesh

  2. #2
    Join Date
    Dec 2002
    Posts
    305

    Re: Doubt about toolbar......

    In the click event handler sub of toolbar, use e.button to identify the button. Example:


    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("Clicked Button1")
    elseif e.button.Text="Button2" Then
    MsgBox("Clicked Button2")
    End If
    End Sub

    Good luck

  3. #3
    Join Date
    Jul 2006
    Location
    At home
    Posts
    70

    Re: Doubt about toolbar......

    Better code would be to get the button based on it's index.

    Code:
    Private Sub Toolbar1_ButtonClick _ 
    (ByVal sender As Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) _ 
    Handles Toolbar1.ButtonClick
    
            Select Case Toolbar1.Buttons.IndexOf(e.Button)
                Case 0
                   'process...
                Case 1
                    'process...
            End Select
    
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured