Resize elements according to form size

Asked

Viewed 3,397 times

0

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

Padrão de tela

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

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

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

1 answer

3


Use the Anchor property of the control

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

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


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

I defined the property Anchor as Top | Bottom | Left | Right. Meaning that no matter which side of my form changes, 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.

Forms com tamanhos diferentes e panel redimensionado

Browser other questions tagged

You are not signed in. Login or sign up in order to post.