Hello everybody!
I am trying to create a UserControl that act as a (Expandable Panel).
I created a UserControl (LGradientPanel) with two panels in it: LCaptionPanel and the LInnerPanel. The last one should "hold" the controls I will add to the UserControl.
The LCaptionPanel will have a gradient fill and the text (caption) of the panel. No controls should be added to this panel.
The LInnerPanel is the container area and shoul hold the controls dragged from the VisualStudo toolbox.
How can I "tell" the designer that ONLY the LInnerPanel should accept controls (dropped from the toolbox) ?
The problem I am getting is that when I drag controls into the GradientPanel, the controls are inserted in the LGradientPanel control. At run time, in the InitializeComponent(), I can see the following command line:
this.lGradientPanel2.Controls.Add(this.textBox3);
I want to add them into the LInnerPanel. How can I do that? Something like
this.lGradientPanel2.InnerPanel.Controls.Add(this. textBox3);
Here is the structure I am using:
namespace LXPControls
{
internal class LCaptionPanel : System.Windows.Forms.Panel
{
(...)
public LCaptionPanel()
{
SetStyle(ControlStyles.ResizeRedraw, true);
SetStyle(ControlStyles.Opaque, true);
SetStyle(ControlStyles.Selectable, true);
SetStyle(ControlStyles.ContainerControl, false);
SetStyle(ControlStyles.SupportsTransparentBackColo r, true);
(...)
}
internal class LInnerPanel : System.Windows.Forms.Panel
{
(...)
public LInnerPanel()
{
SetStyle(ControlStyles.ResizeRedraw, true);
SetStyle(ControlStyles.Opaque, true);
SetStyle(ControlStyles.Selectable, true);
SetStyle(ControlStyles.ContainerControl, true);
SetStyle(ControlStyles.DoubleBuffer, true);
SetStyle(ControlStyles.SupportsTransparentBackColo r, true);
(...)
}
[Designer("System.Windows.Forms.Design.ParentContro lDesigner, System.Design", typeof(System.ComponentModel.Design.IDesigner))]
public class LGradientPanel : System.Windows.Forms.Control
{
(...)
private LCaptionPanel captionPanel;
private LInnerPanel innerPanel;
(...)
public LGradientPanel()
{
SetStyle(ControlStyles.ResizeRedraw, true);
SetStyle(ControlStyles.Opaque, true);
SetStyle(ControlStyles.Selectable, true);
SetStyle(ControlStyles.ContainerControl, false);
(...)
}
}
Does anybody have an idea on what I am doing wrong?
Thanks everybody
Regards,
Carlos