Dynamic controls go wonky

  • Thread starter Thread starter et
  • Start date Start date
E

et

I have the situation where a C# dll is loaded and it provides some
controls to display, I wrap the controls in some nice group boxes, and
later on I dispose of the group boxes, making sure I remove the
controls since I don't want them to be disposed of yet.

If I do this a couple of time ie. wrapping controls in my group boxes
and setting the references of the group boxes to nothing while keeping
a reference to the controls, the controls seem to exhibit a weird
behaviour, the listbox controls seem to loose their events, and the
other controls that have the default , start using some wierd font,
and not that of the parent. The behaviour has something to do with the
dipose event, but I cannot figure this out.

Kind regards
Boom
 
et,

Before you dispose of the group boxes, do you actually remove the
controls from the Controls collection? If you don't then when you call
Dispose, it will most likely dispose of the child controls as well.

Also, why do you need to save the controls? Why not just store the
information you need and place it into new instances?

Hope this helps.
 
Back
Top