UserControl with a "Container panel" problems

T

TheSteph

Hi !



I would like to create a UserControl that act as a « Collapsible Panel ».



So I have a UserControl with two panels : a "Header panel" at the top, and a
"Container Area Panel" docked to fill the remaining client area of the
UserControl.



The "Header panel" is for Text, Icon,.

The "Container Area Panel" is to host all the Control dragged from the V.S.
toolbox.



How can I tell the designer that the "Container Area Panel" ONLY should
accept controls (dropped from the toolbox) ?



Actually my "Container Area Panel" has public modifiers.

I tried with that statement just above the declaration of my
CollapsiblePanel Class



[Designer(typeof(CollapsiblePanelDesigner))]





And I have made this class:





public class CollapsiblePanelDesigner : ParentControlDesigner

{

public override void Initialize(System.ComponentModel.IComponent
component)

{

base.Initialize(component);

CollapsiblePanel TmpCollapsiblePanel = component as CollapsiblePanel;

EnableDesignMode(TmpCollapsiblePanel.ClientPanel,
TmpCollapsiblePanel.ClientPanel.Name);


}

}



But this doesn't work .. I can drop controls on my CollapsiblePanel, but
designer allow to drop them also on the "Header Panel" (It shouldn't) . And
the Designer "forget" to add the controls to the "Container Area Panel" at
run time : in the InitializeComponent() the control on the CollapsiblePanel
are never added to the control (this line is missing [not generated]:
this.CollapsiblePanel1.Pan_Container.Controls.Add(Textbox1);)



Does anybody have an idea on what I'm missing ??



Thanks for any help or comments,



Steph.
 
T

TheSteph

OK, It works now !

I forgot to put the
"[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]"
statement above the propety that publish the "Container Panel" :

[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public Panel ContainerPanel
{
get
{
return Pan_Container;
}
}//EndProp ContainerPanel
 

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