Thanks in advance

i created my own toolbar from user control option
i design and add all button ADD,EDIT,DELETE,LOOKUP,CLOSE
and build this class and drag on my form
now i want to use click event of every button but there is only one click event

Public Class Form1

Private Sub Kk_toolbar1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Kk_toolbar1.Click

End Sub

and i want btndelete_click()

thanks
Khurram

Was your toolbar based on WinForms ToolBar control?

Here's a very simplified example which uses ToolBar control with two ToolStripButton controls, just to show the idea. First the user control itself

Public Class UserControl1

  Public Event AddClick(ByVal sender As System.Object, ByVal e As System.EventArgs)
  Public Event EditClick(ByVal sender As System.Object, ByVal e As System.EventArgs)

  Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
    RaiseEvent AddClick(sender, e)
  End Sub

  Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
    RaiseEvent EditClick(sender, e)
  End Sub

End Class

which "forwards" ToolStripButton.Click events outside of the user control.

And here's the form which uses the control

Public Class Form2

  Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    
  End Sub

  Private Sub UserControl1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles UserControl1.Click

  End Sub

  Private Sub UserControl1_AddClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles UserControl1.AddClick
    ' Handle Add-button click (= ToolStripButton1.Click)
  End Sub

  Private Sub UserControl1_EditClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles UserControl1.EditClick
    ' Handle Edit-button click (= ToolStripButton2.Click)
  End Sub

End Class

Of course, this is not the only way to do it. You may declare your event parameters differently etc.
Hope you get started with this.

This article has been dead for over six months. Start a new discussion instead.