Question

I'm developing a control which inherits from a System.Windows.Form.Panel. The idea is very simple: a toolbar at the bottom of the panel, a region in which you can drop any control you want. For that area i think about a panel, making this panel public and the user is allowed to drop the control only there. I don't know if anyone of you work with a groupbox from kypton? You have a the group box control and inside a panel and if you see the document outline view you'll notice something like this: kryptongroupbox1 |--> panel1. And all the controls are dropped in panel 1. I want to do something like that. Any idea?

Here is my code:

public partial class GridPanel : Panel
{

    private System.Windows.Forms.ToolStripButton cb_print;
    private System.Windows.Forms.ToolStripButton cb_excel;
    private System.Windows.Forms.ToolStrip tool;
    private System.Windows.Forms.ToolStripButton cb_filter;
    private System.Windows.Forms.ToolStripButton cb_ocultar;
    private System.Windows.Forms.ToolStripButton cb_restaurar;
    private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
    private System.Windows.Forms.ToolStripLabel lb_cantrow;

    [Description("The internal panel that contains group content.")]
    [Localizable(false)]
    [Category("Appearance")]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    public Panel Panel { get; set; }

    public GridPanel()
    {
        InitializeComponent();
        InitCustomComp();
        this.Panel = new Panel{ Dock = DockStyle.Fill, BackColor = Color.Transparent };
        this.Controls.Add(Panel);
       // this.Controls.Add(new KryptonDataGridView { Dock = DockStyle.Fill });
    }

    private void InitCustomComp()
    {

       // the creation of the toolbar
    }

    public GridPanel(IContainer container)
    {
        container.Add(this);

        InitializeComponent();
    }
}

with my approach I can drop controls in my custom control but when I dock (fill) one of then it fit all the control's area behind my toolbar

Sorry if the explanation is a bit confusion. English is not my native language.

Était-ce utile?

La solution

Probably the control is added to outer panel instead of the internal panel.

This issue is explained in this The Code Project article: Designing Nested Controls. Henry Minute explains how he solved this problem.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top