Custom User Control

Please support our VB.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Reply

Join Date: Jan 2009
Posts: 1
Reputation: itzkhurram is an unknown quantity at this point 
Solved Threads: 0
itzkhurram itzkhurram is offline Offline
Newbie Poster

Custom User Control

 
0
  #1
Jan 10th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 710
Reputation: Teme64 will become famous soon enough Teme64 will become famous soon enough 
Solved Threads: 114
Teme64's Avatar
Teme64 Teme64 is offline Offline
Master Poster

Re: Custom User Control

 
0
  #2
Jan 10th, 2009
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
  1. Public Class UserControl1
  2.  
  3. Public Event AddClick(ByVal sender As System.Object, ByVal e As System.EventArgs)
  4. Public Event EditClick(ByVal sender As System.Object, ByVal e As System.EventArgs)
  5.  
  6. Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
  7. RaiseEvent AddClick(sender, e)
  8. End Sub
  9.  
  10. Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
  11. RaiseEvent EditClick(sender, e)
  12. End Sub
  13.  
  14. End Class
which "forwards" ToolStripButton.Click events outside of the user control.

And here's the form which uses the control
  1. Public Class Form2
  2.  
  3. Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  4.  
  5. End Sub
  6.  
  7. Private Sub UserControl1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles UserControl1.Click
  8.  
  9. End Sub
  10.  
  11. Private Sub UserControl1_AddClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles UserControl1.AddClick
  12. ' Handle Add-button click (= ToolStripButton1.Click)
  13. End Sub
  14.  
  15. Private Sub UserControl1_EditClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles UserControl1.EditClick
  16. ' Handle Edit-button click (= ToolStripButton2.Click)
  17. End Sub
  18.  
  19. 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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC