3

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)

0

1 Answer 1

6

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 :

1
  • I didn't know it... thank you, it seems to be applied to my case.
    – mzurita
    Commented Jun 14, 2016 at 8:42

Not the answer you're looking for? Browse other questions tagged or ask your own question.