Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have Implemented One C# Windows Application and the Project is Almost completed.
When i maximized window then on right side space is create .

i want my all control size is increase/decrease as window is maximized/minimized.
please help
Posted

Windows Forms has never provided a really powerful re-locate/re-size on re-size model; but, in most applications you can achieve good results with using Dock, Padding, and Margin Properties (as Sergey suggests) on the ContainerControls (Panel, GroupBox, FlowLayoutTable, etc.), and the Margin and Anchor Properties on the Controls inside them.

Another alternative is to use a 3rd. party docking/tiling library like Weifen Luo's open-source (free) DockPanelSuite [^].

In terms of a practical solution to your immediate problem, I suggest you follow Tim's suggestion, then test and see what doesn't look right visually, and try using Dock on the involved ContainerControls.

Worst case is you have to write some code in the Form/ContainerControl re-size Events.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 16-Oct-14 12:13pm    
More generalized advice, my 5.
I don't understand "has never provided a really powerful re-locate/re-size on re-size model" though. What would you expect for more powerful model then? — I'm just curious.

Also, I found some glitches in Luo's DockPanelSuite. One feature needs complete re-write: layout save/restore. What Luo offered wasn't universal, required ad-hoc programming to a specific control set, which is of course unacceptable; I never accomplished it...

—SA
BillWoodruff 16-Oct-14 13:57pm    
Hi Sergey,

A more powerful model would allow you to easily create some kind of "re-size/-reposition binding" between Controls/ContainerControls and other Controls/ContainerControls. I've created my own library for this which I think about publishing here, but always find more interesting things to be working on :)

Or, if WinForms offered what WPF offered ... but, saying that is like saying: "if apples offered what oranges offered."

Yes, Luo's Dock library is difficult to use, has problems, and hasn't been maintained for quite a while, I think, but, I don't expect much from most open-source projects.

cheers, Bill
Sergey Alexandrovich Kryukov 16-Oct-14 14:27pm    
Would be interesting to take a look — any publications?
Thank you.
—SA
It's not a good idea to design it this way. Instead, you should better define the layout which is rearranged nicely as you resize the window. Please see my past answers:
Zom Out malfunctions when Screen resolution changes[^] (a simple code sample here),
how to dock button so that it can adjust with the form[^].

See also this one: GUI Apperance - C#.Net[^].

Prefer using the Control properties Dock and Padding over Anchor (which still involves manual resize and causes flicker in some controls).

—SA
 
Share this answer
 
Comments
TimWallace 16-Oct-14 1:55am    
There are multiple "better" ways to accomplish control resizing. The OP indicated they were almost done with the app, so I gave them the fastest way to accomplish the end goal.
Sergey Alexandrovich Kryukov 16-Oct-14 2:06am    
Well, I don't know why the way should be "fastest". How about better?
—SA
BillWoodruff 16-Oct-14 3:03am    
+5 This answer addresses what the OP really needs, which, unfortunately, he may not realize is more than what he wants. I've added a "solution" here that suggests a bit of both your and Tim's medicine ... and which I don't expect you to find satisfactory :)
Sergey Alexandrovich Kryukov 16-Oct-14 12:13pm    
Thank you, Bill.
—SA
You could anchor all of your controls to the left, right, top and bottom.
 
Share this answer
 
Comments
Rahulmishra011 16-Oct-14 1:35am    
sir there are many control so sir its is very time takeing some another way suggest me plz
TimWallace 16-Oct-14 1:43am    
Select all of the controls using "ctrl a", then set the anchor property... it will set it for them all at once.
BillWoodruff 16-Oct-14 3:05am    
+5 This answer addresses what the OP wants, which, unfortunately, he may not realize is not the same as what he really needs. But, it's a good practical answer !
You need use proper anchor and dock property of controls.
 
Share this answer
 
Create your layout using TableLayoutPanel. Just make DOCK=FILL Property Of TableLayoutPanel.
Now Place your control inside TableLayoutPanel and Make The DOCK=FILL for all controls.
 
Share this answer
 

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