Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / December 2005

Tip: Looking for answers? Try searching our database.

Raise Events in a control inside another

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Martin - 22 Dec 2005 15:25 GMT
In a VB.NET windows forms
I have a custom control which I have added a number of instances to a panel
control.  I want to raise a event when one of the controls on one of the
custom controls is changed etc.  and trap this event in the Form code where
the panel is

Each copy of the control is created and added to the panel using items.add()
RickHodder - 27 Dec 2005 03:49 GMT
Hi Martin,

You basically want to
1. Create a method on the form that you want to run when the event on any of
the controls is raised.
2. Use AddHandler to link each of the custom controls to the method created
in 1.

For example, lets say that you have a control called MyCustomControl, and it
has an event called MyEvent, that passes a reference to the MyCustomControl
that raises the event.

Public Class frmTest

' This is the method that the
Sub HandleCustomControlEvents(ByRef oControl As MyCustomControl)
   MessageBox.Show(oControl.Name & " fired its event")
End Sub

Private Sub frmTest_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim cntControl As MyCustomControl

cntControl = New MyCustomControl()

AddHandler cntControl.MyEvent, AddressOf HandleCustomControlEvents

Me.Controls.Add(cntControl)

End Sub

End Class

Hope this helps
Rick Hodder

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.