Add new control at runtime and assign events

Drstein99

Junior Contributor
Joined
Sep 26, 2003
Messages
283
Location
Audubon, Nj
I can create a textbox and assign the control at runtime, and retrieve data with no problem.

Is there a way I can assign one of my functions in my code at designtime as the event handler for the new control at runtime?

In other words, I want to create a data validation keypress event, at designtime, and at runtime create a textbox and assign it's keypress event to the one in the module. Please help, thanks.
 
Look into the AddHandler keyword. It will add a handler for an event for a control at runtime.
Visual Basic:
AddHandler object.event, AddressOf  methodtobethehandler
 
I checked it out and the vb.net help was descriptive enough to help me solve my issue (surprisingly). Thanks for the point in the right direction, it solved my issue - case closed!
 
hello sir i am tanmoy.i have created a textbox in runtime.now i want to assign some events from this runtime controll.like retrive the value of the textbox or click event.please tell me how can i do this as quick as possible.thank you.my email id is:sadhuambarish2005@yahoo.co.in
 
Retrieving the value of a textbox would assumbably be done using the .Text property which is not an event but a property. Adding a click event is reasonably simple, and there is already an example of how this is achieved in VB.Net
Visual Basic:
AddHandler object.event, AddressOf  methodtobethehandler
 
Back
Top