Resize elements according to the size of the form

0

I have GroupBox within a Form that has the following pattern:

Padrão de tela

- Form: 1290;700
- GroupBox Principal: 1260;600

This Form is opened through MDI. I use a function to center this form according to the size of the monitor!

However, I encountered the following problem when I try to open the system on a monitor that is not wide and the resolution is 1024X768 so my GroupBox is cut off. How could I do to Form have automatic sizing along with all TextBox , ComboBox , Grids that are inside it?

    
asked by anonymous 03.03.2016 / 16:48

1 answer

3

Use the Anchor property of the control

All WinForms controls have a property called Anchor , this property serves just to define the component behavior when its Parent (or Parent , and so on) is resized.

Basically, you must define which side (s) of the component that will follow the component Parent .

Here's an example (I used Panel instead of GroupBox for better visualization, but the idea is the same).

I set the Anchor property to Top | Bottom | Left | Right . It means that no matter what side of my form is changed, the panel will always have the same distance between the edges.

On the left side is the form with 200x200 and on the right side is the same form with 500x500.

    
14.04.2016 / 22:27