Adding controls to a panel in a UserControl?

G

Guest

I'm developing a UserControl that has 2 panels - one docked top and the other fill. I want to be able (at design time) to drop controls on the panel docked to fill, but when I do so, the newly added control is added to the base UserControl's control collection and not the "fill" panel. Intercepting the OnControlAdded event and changing the parent of the new control just gives me an error message "'child' is not a child of this parent". Bringing the new control to the front doesn't work either as it's still parented by the base control and is "painted over" at runtime by the fill panel. I thought this was an easy one, but I've spent a couple of days (and nights) on it. Any help at all is really appreciated
Thanks in advance. Tim
 
S

Stoitcho Goutsev \(100\) [C# MVP]

Hi Tim,

You ave to add some design time support to your control.
Check yout the articles in this site. I believe you'll find some useful ones


--
B\rgds
Stoitcho Goutsev (100) [C# MVP]
Tim Swords said:
I'm developing a UserControl that has 2 panels - one docked top and the
other fill. I want to be able (at design time) to drop controls on the
panel docked to fill, but when I do so, the newly added control is added to
the base UserControl's control collection and not the "fill" panel.
Intercepting the OnControlAdded event and changing the parent of the new
control just gives me an error message "'child' is not a child of this
parent". Bringing the new control to the front doesn't work either as it's
still parented by the base control and is "painted over" at runtime by the
fill panel. I thought this was an easy one, but I've spent a couple of days
(and nights) on it. Any help at all is really appreciated.
 
G

Guest

Thanks Stoitcho. I was afraid that was the path I needed to take. I guess it's time to roll up the sleeves and get dirty.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top