开发者

Universal control - simple question about dock and anchor

开发者 https://www.devze.com 2022-12-25 09:04 出处:网络
I use Visual Studio .NET to develop internal applications. I create a Windows control that will display custom status bar information. Different developers will use the control to display the same inf

I use Visual Studio .NET to develop internal applications. I create a Windows control that will display custom status bar information. Different developers will use the control to display the same information in many开发者_开发问答 different applications. The control must always be displayed at the bottom of the parent form in every application. It must always be as wide as the form. When the form is resized, the control should be resized and repositioned accordingly. How should I do that in the best way and why? A)Create a property to allow the developers to set the Dock property of the control. Set the default value of the property to AnchorStyle.Bottom. B) Create a property to allow the developer to set the Anchor property of the control. Set the default value of the property to AnchorStyle.Bottom.


If you want your control to always be at the bottom of it's container then you should use the Dock property. Docking a control attaches the control to an edge of it's container or fill the container completely.

Using Anchor defines a constant distance between one or more edges of it's container.

Thanks

Barry


Dock is what you are after for this - take a look at the Statusbar control to see.

Something like this should cover it:

  [DefaultValue(2)]
  public override DockStyles Dock {
    get { return base.Dock; }
    set { base.Dock = value; }
  }

Edit: Seems that 2 is Bottom

0

精彩评论

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

关注公众号