Well, there's a question mark at the end of that statement ;-)
My assumption was that these handlers are objects which might become
"orphaned" somehow,and cause a problem, if the objects whose events they
were added to have been destroyed.
Do I understand from your own socratic question that I can dynamically add a
bunch of controls to my form, add handlers to specific events for these
controls, and then remove those controls from the form, and then add new
ones, possibly with the same names and with their own set of comparable
handlers, all without undesirable side-effects?
To be specific: I'm working with a grid control that lets you add rows
dynamically, changing cell editors as required by the datatype in question.
I'm using the same grid as a front-end to various database tables. Depending
upon a user's menu selection (Employees, Vendors, Customers, etc) I delete
all the rows in the grid and then recreate the grid with new rows, editors,
and handlers appropriate for the table in question. Some of the tables have
100 columns, so there could be quite a few of these "left-over" handlers
hanging around -- if, indeed, they do hang around?
Thanks
Timo
Alvin Bruney said:
why do you think it is a good practice?
--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
Timo said:
I assume its a good practice to remove handlers attached to an object's
events before destroying the object?
Is there a way to examine an object to get a list of eventhandlers that have
been attached, via AddHandler, to the object's events, so a method can
iterate through that list and invoke RemoveHandler for each item in it?
Thanks!
Timo