Results 1 to 4 of 4

Thread: Need help with Events

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2004
    Location
    LA
    Posts
    57

    Question Need help with Events

    Hello,

    Can some one help me? I need to trigger a specific toolbar button Click event when I click menu item.

    Thank you.

  2. #2
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi,

    Same way as you call any objects Click Event. But if you have the necessary button on the toolbar, why are you also referring to it in a Menu? Are you saying that you are not including the toolbar on your form but want to activate the code contained in one of the toolbar buttons?
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Incase you're creating this at runtime then you have to do this :
    VB Code:
    1. AddHandler ToolBar1.ButtonClick, AddressOf Me.ToolBarCustomHandler
    2.  
    3.  
    4. Public Sub ToolBarCustomHandler(ByVal sender As system.Object,
    5. ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs)
    6. Handles ToolBar1.ButtonClick
    7.  
    8. 'Do your stuff here
    9. End Sub


    If the toolbar buttonclick event is already created then just do this :

    VB Code:
    1. Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
    2.         Dim btn As String = e.Button.Text
    3.  
    4.         Select Case btn
    5.  
    6.             Case "Add"
    7.                 MsgBox("add button was clicked")
    8.             Case "Edit"
    9.                 MsgBox("edit button was clicked")
    10.             Case "Search"
    11.                 MsgBox("search button was clicked")
    12.         End Select
    13.  
    14.     End Sub
    15.  
    16.  
    17.  
    18. 'From your menuitem , you can call the edit button like this :
    19.  
    20. Me.ToolBar1_ButtonClick(Me, New ToolBarButtonClickEventArgs(New ToolBarButton("Edit")))

  4. #4

    Thread Starter
    Member
    Join Date
    Feb 2004
    Location
    LA
    Posts
    57
    Thank you very much it works great


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