tags:

views:

57

answers:

2

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.

A: 

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

Pondidum
A: 

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

Barry