开发者

Own component with panel

I wa开发者_如何学运维nt to create my own component which consists two other panels. One of them has fixed contents (such as control buttons, etc.) and the other is standard panel, where I can add other components in designer (VS2008). I know that I have to create UserControl, where I can place my two panels. Then I want to insert my component into the form. But I don't know how to create behavior where I can add other components (such as buttons, labels, etc.) only into second panel in my component. Could anyone help me with creating this component?

Thank you. Adam.


Here is an example (snippet of working code):

  [Designer(typeof(NavigationalUserControl.Designer))]
  public partial class NavigationalUserControl : UserControl
  {
    class Designer : ControlDesigner 
    {
      public override void Initialize(IComponent component)
      {
        base.Initialize(component);
        var nc = component as NavigationalUserControl;
        EnableDesignMode(nc.panel2, "ContainerPanel"); 
        EnableDesignMode(nc.bottomPanel, "BottomPanel");
      }
    }

    // rest of normal class
  }


I have found the correct solution (I hope). I have added into my UserControl a property which returns the content panel with this specific Attribute:

[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public Panel PanelContent
{
   get { return this.panel2; }
}

Thanks for your help leppie

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜