Handling Check-Boxes those are created Run-Time

abhaychauhan

New member
Joined
Jan 23, 2007
Messages
1
Programming Experience
1-3
I hav Created a Windows application in which Check-Boxes are created runtime with the names stored in a Database. I hav given the command to create a New CheckBox within a 'for' loop and "checkbox.name = as specifed in the Database."

I want to use the different events (e.g. Click, Checked...) to handle these CheckBoxes runtime. But...as there is no instance or declaration for the CheckBoxes specified (..those are getting created when the program runs) while writing the codes, I m not able to further control the checkboxes after these are checked runtime.

Please help me out of this problem...:confused:
 
You can hook up events for dynamically created controls, and controls created at design time with the AddHandler keyword, all you need is a methods with the same delegate signature as the generated event handler...

VB.NET:
AddHander CheckBox.CheckedChanged, AddressOf SomeMethod
 
 
Public Sub SomeMethod(byval sender as object, byval e as System.EventArgs)
 
Handle the event here...
 
End sub.

VB.NET:
Unhook the control..
 
RemoveHander CheckBox.CheckChanged, addressof SomeMethod
 
Back
Top