Results 1 to 5 of 5

Thread: [RESOLVED] Form and controls resize using Anchor/Dock

Hybrid View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    135

    Resolved [RESOLVED] Form and controls resize using Anchor/Dock

    Hello,

    From this forum I saw some discussions about form/controls resizing issue with different resolution screen setting. Most suggestions are using Anchor/Dock. My application's form has 10 group boxes and some buttons. In each group box there are 5 Text boxes and other more controls. I tried anchor and dock but couldn't make it work. My questions are -

    1, How to re-size form and all individual controls as well?
    2, If anchor/Dock are suggested, do i have to use both of them or just one? it seems to me there is no big difference between them.

    Thanks.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Form and controls resize using Anchor/Dock

    You would pretty much never use Anchor and Dock at the same time on the same control. Docking means a control is attached to a specific edge of its parent or all four edges, while anchoring means that a control is kept at a specific distance from one or more edges of its parent.

    Docking and anchoring can only do so much on their own. If you have a complex layout then you will probably also need to include one or more TableLayoutPanels and/or FlowLayoutPanels. For instance, if you have four GroupBoxes and you wanted them to occupy a quarter of the form each, you would add a TableLayoutPanel, set its Dock to Fill, add two columns each with a width of 50%, add two rows each with a height of 50%, then add a GroupBox to each cell of the TableLayoutPanel and set their Dock or Anchor properties appropriately.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    135

    Re: Form and controls resize using Anchor/Dock

    Quote Originally Posted by jmcilhinney View Post
    You would pretty much never use Anchor and Dock at the same time on the same control. Docking means a control is attached to a specific edge of its parent or all four edges, while anchoring means that a control is kept at a specific distance from one or more edges of its parent.

    Docking and anchoring can only do so much on their own. If you have a complex layout then you will probably also need to include one or more TableLayoutPanels and/or FlowLayoutPanels. For instance, if you have four GroupBoxes and you wanted them to occupy a quarter of the form each, you would add a TableLayoutPanel, set its Dock to Fill, add two columns each with a width of 50%, add two rows each with a height of 50%, then add a GroupBox to each cell of the TableLayoutPanel and set their Dock or Anchor properties appropriately.
    Thanks for your quick reply. But how to resize the form - I made From with resolution1680x1050 and ran in another computer with resolution 1024x768. Part of the Form was out of the screen and the label characters contains more percentage in the group box.

    Thanks,

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Form and controls resize using Anchor/Dock

    Quote Originally Posted by zhengsimon View Post
    Thanks for your quick reply. But how to resize the form - I made From with resolution1680x1050 and ran in another computer with resolution 1024x768. Part of the Form was out of the screen and the label characters contains more percentage in the group box.

    Thanks,
    This is part of application design and should be considered before you write one scrap of code or start designing a single form. Think about who your target audience is. If you expect people to use your app on screens with a resolution 1024x768 then you shouldn't be designing a form whose default size is greater than that. You should be designing your app such that it can work on the minimum spec you expect to encounter and you should then document that minimum spec. If you've used the principles I've described correctly then anyone on a higher res monitor can stretch or maximise your form and it will reflow its child controls appropriately.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    135

    Re: Form and controls resize using Anchor/Dock

    Quote Originally Posted by jmcilhinney View Post
    This is part of application design and should be considered before you write one scrap of code or start designing a single form. Think about who your target audience is. If you expect people to use your app on screens with a resolution 1024x768 then you shouldn't be designing a form whose default size is greater than that. You should be designing your app such that it can work on the minimum spec you expect to encounter and you should then document that minimum spec. If you've used the principles I've described correctly then anyone on a higher res monitor can stretch or maximise your form and it will reflow its child controls appropriately.
    Thanks a lot!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width