-
Mar 7th, 2010, 03:25 PM
#1
Thread Starter
Addicted Member
[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.
-
Mar 7th, 2010, 07:20 PM
#2
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.
-
Mar 8th, 2010, 10:53 AM
#3
Thread Starter
Addicted Member
Re: Form and controls resize using Anchor/Dock
Originally Posted by jmcilhinney
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,
-
Mar 8th, 2010, 07:19 PM
#4
Re: Form and controls resize using Anchor/Dock
Originally Posted by zhengsimon
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.
-
Mar 9th, 2010, 08:10 AM
#5
Thread Starter
Addicted Member
Re: Form and controls resize using Anchor/Dock
Originally Posted by jmcilhinney
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|