How to make Change event handled in one sub

  • Thread starter Thread starter clara
  • Start date Start date
C

clara

Hi all,

On one of my form, there are over 40 combobox, textbox, and other controls.
If change happens in combobox or textbox, a change flag should be set. I hope
these events should be handled in one sub. I hope I can do it in the
following format:

for each con in me.controls

addhandler -----, deleg

next

Could you tell me how?

Clara
 
for each con as Control in me.Controls
dim ed as EventDescriptor = TypeDescriptor.GetDefaultEvent(con)
ed.AddEventhandler(con, [delegate])
next

I did my testing in C# so you might have to do some importing to get
it working but it does work. I use the Default event since it tends
to be "TextChanged", "SelectedIndexChanged", "ValueChanged", etc....
 
cfps.Christian said:
for each con as Control in me.Controls
dim ed as EventDescriptor = TypeDescriptor.GetDefaultEvent(con)
ed.AddEventhandler(con, [delegate])
next

Note that this loop won't enumerate nested controls.
 
Back
Top