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
Printable View
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
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
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