Okay, now, don't do this to me.
I've got a form, onto which I place a TabControl; on the various tab pages, I place panels, labels, etc. Everything is created dynamically. When each control is created, I add the name of that control to an ArrayList on the form.
When the form closes, I read through the ArrayList, from bottom to top, and dispose of each control.
This all works very will *until* I get to the TabControl. Running within the IDE doesn't produce any errors, but compile (optimized) for the device, and the Control( name ).Dispose produced an Invalid Cast Exception error.
The error occurs when I try to dispose of the TabControl.
I also started checking the type of the control before disposal, and using Control( name, TabControl ).Dispose. Same problem.
I imagine that, instead of disposing of the tab control, I could just remove all of the tab pages and set the visible to false; but I'd rather dispose of it.
Anyone?
Gary
:sign0085:
I've got a form, onto which I place a TabControl; on the various tab pages, I place panels, labels, etc. Everything is created dynamically. When each control is created, I add the name of that control to an ArrayList on the form.
When the form closes, I read through the ArrayList, from bottom to top, and dispose of each control.
This all works very will *until* I get to the TabControl. Running within the IDE doesn't produce any errors, but compile (optimized) for the device, and the Control( name ).Dispose produced an Invalid Cast Exception error.
The error occurs when I try to dispose of the TabControl.
I also started checking the type of the control before disposal, and using Control( name, TabControl ).Dispose. Same problem.
I imagine that, instead of disposing of the tab control, I could just remove all of the tab pages and set the visible to false; but I'd rather dispose of it.
Anyone?
Gary
:sign0085: