今天想作個自定義容器控件,可是在網上找了半天都沒有找到,能夠在對應的panel裏進行拖拽控件的,多以今天寫一下關於怎麼作一個自定義容器控件設計模式
自定義容器控件須要在自定義控件中加入ide
1 [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] 2 public Panel ControlList 3 { 4 get 5 { 6 return this.dSkinPanel2; 7 } 8 }
ControlList這裏是放容器的區域,能夠在設計模式下拖入控件
設計模式的設計實體:this
public class XYPanelDesigner : ControlDesigner { private XYPanel ucFoldPanelControl; public override void Initialize(IComponent component) { base.Initialize(component); ucFoldPanelControl = (XYPanel)component; this.EnableDesignMode(ucFoldPanelControl.ControlList, "ControlList"); } }
this.EnableDesignMode(ucFoldPanelControl.ControlList, "ControlList");這句就是在哪一個控件進行設計
自定義控件的中插入:
[Designer(typeof(XYPanelDesigner))] public partial class Panel : UserControl {
這句話主要是爲了自定義控件綁定哪一個設計器 [Designer(typeof(XYPanelDesigner))]spa
這樣就能夠製做自定義的容器控件了,想在哪裏當容器均可以設計
文采很差不太會寫,但願這篇文章能夠幫助你們code