Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

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[^] :-).

—SA
 
Share this answer
 
v2
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[^]
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 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 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 17-Jun-11 9:49am    
Small Query, This Code is for Panels. How to add All Fields which I created in designer mode.
OriginalGriff 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.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900