mzurita mzurita -5 years ago 157 Question

Make a responsive form in design view (not programmatically)

I am doing a WinForms program which should have a fully responsive design in a full screen.

I get an approach which works more or less well. It consists into calculate a ratio between display screen and original form size.
Then I apply this ratio to the width, left, height, top properties of each control inside the form.

My doubt is about to use a native way for doing this, since, using anchors, the controls keep their same distances with parent control borders, but I doesn't do proportionally, for instance:

Form with 100x100
Button 20x20 located in (10,10)

If I resized the form to 200x200 (multiply by 2), the best approach I can do in design view is keeping the four anchors to the button, so button size will be 120x120 at the same position (10,10), while what I need is a button with size 40x40, at position (20,20), since form size was multiply by 2.

Is it possible with winforms native operations in design view? (Avoiding to make calculations)

Answer Source

Yes it is possible.

Using the Property Dock = Fill you can ask for a component to take all the room in its container.

Now using a TableLayoutPanel, you can define cells to put your components in. And giving cell a percentage size, you can make sure the sizes will change when the form is resized...

Here are more information on these things :

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download