-
August 17th, 2006, 10:43 AM
#1
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
-
August 17th, 2006, 11:19 AM
#2
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
-
August 18th, 2006, 05:49 AM
#3
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|