Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hi,
 
I am Back with Query again, :P
 
I set All Field of Form1 in Vb.Net 2008 with Designer Mode.
 
Now I want to Set All Field Size & Location as user increases or decrease the form size.
 
Like If User Increases Form1 Size All Fields have to Increase Size & Location Dynamic Relate to Form's Size.
 
If user Decrease the Form1 Size All Fields have to Decrease Size & Location Dynamic Relate to Form's Size.
 
(E.G. Android SDK Installer, ACD See Viewer)
 
How to Code for It?
 
Thanks
Posted 15-Jun-11 22:00pm
s1a2b3643
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You can code it manually, in the Resize event, or you can do it one of two other ways:
For a simple form, look at the Anchor[^] property.
 
For more complex forms, look at setting up panels and using the Dock[^] property instead. SAKryukov has an explanation of this a solution to this question: how to dock button so that it can adjust with the form[^]
  Permalink  
Comments
SAKryukov at 16-Jun-11 3:18am
   
Voting less than 5 would be unfair on my side :-)
Thank you for reminding me of my past answer which I failed to add to my re-use reference list. I credited it in my answer.
 
Look at the difference in approaches, in first sentense:
Yours: "You can code it manually...".
Mine: "Simply stop doing it all manually." -- at first I thought I double-posted. :-)
 
I'm still against Anchor, but it's better then manual :-)
--SA
OriginalGriff at 16-Jun-11 3:25am
   
:laugh: - I'm still pro Anchor for very simple forms, but doing it manually (while a total PITA) can be the only way to make it look good without going to WPF, if only because you can resize fonts and so forth if you need to. Not an option I would want to take often though.
s1a2b3 at 17-Jun-11 9:49am
   
Small Query, This Code is for Panels. How to add All Fields which I created in designer mode.
OriginalGriff at 17-Jun-11 9:51am
   
It uses panels to hold the controls - if you look at the code you will see what he is doing.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Simply stop doing it all manually. Never use explicit sizes and location. Use many pad panels and Dock properties with Padding. It will automatically layout everything. In some cases, you can adjust container panel sizes to contents in code. Avoid Anchors property; anchored Form still needs manual alignment (can be inaccurate) and tends to flicker in resize.
 
See also my past answers on the topic:
Zom Out malfunctions when Screen resolution changes[^] — this is about tolerance to screen resolution but techniques are the same,
see also:
GUI Apperance - C#.Net[^],
Code behind class implementation[^].
 
A code sample Griff liked: how to dock button so that it can adjust with the form[^] Smile | :) .
 
—SA
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 240
1 Kamal Rocks 184
2 PIEBALDconsult 150
3 BillWoodruff 148
4 Jochen Arndt 135
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 16 Jun 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100