0

I have written a program in C# (Visual Studio) which makes use of multiple forms. The problem occurs whenever the program is run on a different computer which has a different screen resolution. The contents of the form do not fit into the form whenever the program is run on a computer with a smaller screen resolution. What can I do to make the CONTENTS of the form resize accordingly, depending on the screen resolution so that the contents of the form will always fit, irrelevant of the screen resolution/size of the computer on which it is being run?

Thanks a lot!

Alisinna
  • 121
  • 1
  • 3
  • 12
  • Possible duplicate of [How to auto resize and adjust Form controls with change in resolution](http://stackoverflow.com/questions/4248637/how-to-auto-resize-and-adjust-form-controls-with-change-in-resolution) – mammago Dec 14 '16 at 10:22
  • I have already tried this.. It worked for me when resizing the window horizontally(making it of smaller width). However, when resizing the window vertically (making it of smaller height) it did not work. Is there a different method which has to be used for vertical anchoring? @mammago – Alisinna Dec 14 '16 at 10:25

1 Answers1

1

Assuming you are using WinForms, your best bet in this case is to make use of the various container controls included in the framework, like the FLowLayoutPanel and TableLayoutPanel.

If you want to avoid these, use the standard Panel control and make use of Dock property to ensure it fills the required areas correctly. Then use the Dock property on all your controls to make the layout more responsive to different resolutions, and more importantly different DPI settings in Windows.

Gary
  • 742
  • 8
  • 20
  • Thanks! Yes I am using WinForms. Do the Anchoring and Dock properties have the same function? @Gary – Alisinna Dec 14 '16 at 10:30
  • 1
    Anchoring could also be of use. It's different to the Dock method, in that Dock will fill always stretch to fill the Top/Left/Bottom/Right. If you use Anchor, the control will attempt to resize but keep the spacing on the Top/Left/Bottom/Right according to what you originally set. – Gary Dec 14 '16 at 10:35
  • Thank you so much! Will try it out :) @Gary – Alisinna Dec 14 '16 at 11:06