Switching between user controls

Mar 31 2009 12:37 AM
Hi,

I have 8 user controls which occupies the same space on the form. To achieve this, When a new usercontrol is required, I remove the current usercontrol from a container panel on the form and add the new usercontrol to it.

But after 12 or 13 such "switches", the application crashes at

PNL.Controls.Add(panelobj);

This is where I am adding a new usercontrol to the container panel.

The exception raised is "error in creating window handle"

I went through a few forums. They say its because the number of user objects and handles are increasing. But my application cashed when the number of User objects is approx 250, and Handles are around 600 at max. This's a lot lesser considering Outlook users 2000 handles on my system.

Hope to get a solution to this soon.

Regards,
Immanuel