Question Disposed event

Roger-u

New member
Joined
Oct 26, 2020
Messages
2
Programming Experience
10+
I was trying to keep track of a lot of TextBoxes, and using the .Handle seemed the obvious choice...
And when the form closes it fires the textbox_Disposed(sender as object, e as eventargs) event the expected number of times (i.e. the number of textboxes), so far so good... BUT the sender.Handle is not the one for the textbox - it is just a "random" value - well i'm sure it points to something, but not any textbox i knew about.

Any ideas? I'm guessing by the time it calls the disposed event the texbox no longer exists.
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,570
Location
Sydney, Australia
Programming Experience
10+
I would assume that Disposed is raised after the disposal occurs and the main part of that disposal is the release of the Handle. You could just put the TextBox objects themselves in a List and identify them via the sender.
 
Top Bottom