How to make Change event handled in one sub

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
 
C

cfps.Christian

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....
 
H

Herfried K. Wagner [MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top