Raising event from objects within a controls collection
-
Hi. I need some help. I'm trying to add user controls dynamically to a tabpage's controls collection. The problem is, once they've been added, i don't know how to listen for events raised within the user controls. Is there some control-object event handler? HELLLP. Thanks in advance. DI
-
Hi. I need some help. I'm trying to add user controls dynamically to a tabpage's controls collection. The problem is, once they've been added, i don't know how to listen for events raised within the user controls. Is there some control-object event handler? HELLLP. Thanks in advance. DI
Take a look in the help for addhandler. This should do the trick for you.
Paul Watson wrote: "At the end of the day it is what you produce that counts, not how many doctorates you have on the wall." George Carlin wrote: "Don't sweat the petty things, and don't pet the sweaty things." Jörgen Sigvardsson wrote: If the physicists find a universal theory describing the laws of universe, I'm sure the asshole constant will be an integral part of that theory.
-
Hi. I need some help. I'm trying to add user controls dynamically to a tabpage's controls collection. The problem is, once they've been added, i don't know how to listen for events raised within the user controls. Is there some control-object event handler? HELLLP. Thanks in advance. DI
Events are handled in a good new way in .NET. When you want to listen to an event, you do this:
button.Click += new System.EventHandler(buttonClick)
where button.Click is the event, and buttonClick is a method with the correct arguments. When handling multiple controls' events, use the "Sender As Object" argument of the method you assigned to the event to find out which object fired the event.
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi