Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can my form elements resize when the window is resized?

I have this form, with a tab control and a listbox inside:

enter image description here

When I resize the window's height, I get something like this:

enter image description here

However, I actually wanted the tab control and the listbox to resize along, having the following result:

enter image description here

I believe I could achieve this effect by just responding to some kind of onResize() method in the form, and do my own calculations to manually update the size of the tab control and the listbox accordingly.

However, I've seen many applications achieve this effect, so I suspect there is actually a better way to do so - perhaps a builtin feature.

Do you know a better way to achieve this effect?

like image 273
Voldemort Avatar asked Jan 02 '13 04:01

Voldemort


1 Answers

Here is a good tutorial that explains how to resize winform controls on resizing the container form control using the dock and anchor properties:

http://www.techrepublic.com/article/manage-winform-controls-using-the-anchor-and-dock-properties/6165908

Setting the four values of the anchor property(top,right,bottom,left), you can make your control's edges to stay stationary with respect to the Form control even when it is re-sized.

like image 174
Cdeez Avatar answered Oct 08 '22 20:10

Cdeez