Click here to Skip to main content
15,895,423 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi

I want to change windows control size on every main form size change. Suppose if form maximize the inner control size increase and when it restore then inner control size is decrease. For this i am using anchor property of inner control but the actual size increase slowly and not decrease it.
Posted

1 solution

You will have to use both anchoring and docking here. Depending upon the number of controls and which ones should resize or not, you can decide anchoring and docking for the controls.

I personally use TableLayoutPanel control with row and columns sizes set by percentage. Each cell with then have one control in it with Docking set to All. TableLayoutPanel itself will have Docking set to All.

This means that now cells will grow and shrink with the form. As the controls are placed in the cell, they too will grow and shrink.

For the controls that should remain same size, their column and row size must be set to absolute value.

This is quite useful in a form with lots of controls.

Take a look at this. You can also test things at design time itself.
 
Share this answer
 
Comments
Dharmendra-18 18-Jan-13 4:47am    
I can not use the table layout panel.
dan!sh 18-Jan-13 4:59am    
Why?
Dharmendra-18 18-Jan-13 5:11am    
because application is completed with coding
dan!sh 18-Jan-13 5:15am    
So can't change code? If yes, you cannot do anything. TableLayoutPanel should not affect anything unless there Control.Parent property was used anywhere or if Control.Controls collection was used.

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