2012-03-23 79 views
0

我正在开发一个继承自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(); 
    } 
} 

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

对不起,如果解释有点混乱。英语不是我的母语。

回答

0

可能将控制添加到外部面板而不是内部面板。

此问题在此代码项目文章中解释:Designing Nested Controls。亨利分钟解释他是如何解决这个问题的。

+0

太好了。谢谢 – 2012-03-23 16:24:53

相关问题