【发布时间】:2012-03-23 14:11:59
【问题描述】:
我正在开发一个继承自 System.Windows.Form.Panel 的控件。 这个想法非常简单:面板底部的工具栏,您可以在其中放置您想要的任何控件的区域。对于该区域,我考虑了一个面板,使该面板公开,并且只允许用户将控件放在那里。我不知道你们中是否有人使用 kypton 的 groupbox?您有一个组框控件和一个面板,如果您看到文档大纲视图,您会注意到如下内容: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();
}
}
通过我的方法,我可以将控件放在自定义控件中,但是当我停靠(填充)其中一个时,它会适合工具栏后面的所有控件区域
对不起,如果解释有点混乱。英语不是我的母语。
【问题讨论】: