自定义控件中的可编辑区域



我正在开发一个从System.Windows.Form.Panel继承的控件。这个想法很简单:在面板底部有一个工具栏,在这个区域中可以放置任何想要的控件。对于这个区域,我考虑一个面板,将这个面板公开,用户只能在那里放下控件。我不知道你们中有没有人和一个来自凯普顿的群箱一起工作?您有一个组框控件,位于一个面板内,如果您看到文档大纲视图,您会注意到如下内容:kryptongroupbox1|-->panel1。所有的控件都放在面板1中。我想做这样的事。知道吗?

这是我的代码:

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();
    }
}

用我的方法,我可以把控件放在我的自定义控件中,但当我停靠(填充)其中一个控件时,它就适合我工具栏后面的所有控件区域

如果解释有点混乱,很抱歉。英语不是我的母语。

可能控件被添加到外部面板而不是内部面板。

这个问题在代码项目的文章中有解释:设计嵌套控件。Henry Minute解释了他是如何解决这个问题的。

最新更新