Hi,
<Mi************@gmail.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
foreach (Control tb in this.Controls)
if ( tb is TextBox)
tb.Dispose();
worked the same as
foreach (TextBoxtb in this.Controls)
tb.Dispose();
which only disposes every other textbox.
Not at all, if Controls contain another contain that does not derive from/is
a TextBox you will get an exception , your code is error prone, the one I
gave you is not.
just to clarify, when i said "clear", i meant destroy.
Ok, I though u mean to clear the Text property.
Its a user control that dynamically creates a bunch of textboxes when
it loads. Before it loads, i want to destroy any textboxes that were
previously created.
Please note that after you call Dispose you should not access the control
again, this mean you should remove it from the Controls list
Frankly I do not see the need to the code you have, in any case you should
call Dispose of the usercontrol
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation