1

How to make a Windows Forms App to be perspective , in order to make it to be like a web page where all the elements are resizable ?

I mean that it should fill in all screen sizes , laptops and desktops.

I have tried everything but none is working v,

I want all the elements of the form to resize as it would resize if it was a web page?

It is so painful if the Windows Form has many elements and you have to make all the properties in all the controls and when you change one property , maybe then you have to change again another one , and again and again...

I am looking for something like when we make a Web Page , its easier and much more elegant.

LopDev
  • 823
  • 10
  • 26
  • 3
    use WPF instead of Windows Forms. – A_Sk Jan 27 '20 at 09:57
  • [TableLayoutPanel](https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.tablelayoutpanel). Each Cell can contain other containers. Each Cell's measure can be defined as proportional, so when the Container Form is resized, all control inside the TLP are resized proportionally. If this is what you mean. Also, check the `Dock` and `Anchor` properties (all controls). – Jimi Jan 27 '20 at 09:57
  • 1
    Also you'll find searching easier using "_responsive_", rather than "perspective" – Diado Jan 27 '20 at 09:58
  • *you have to make all the properties in* I don't know what that means. When you design a Form, you set the anchors and dock the controls as needed anyway. If you don't, you have a bad design and, as a consequence, a bad layout in undetermined/uncontrolled circumstances. The same applies to web pages. Bad design, bad results. TableLayoutPanels, FlowLayoutPanels, TabControls, SplitContainer etc. are used all the time. If you just slap controls randomly on a Form's surface, you get what you get. – Jimi Jan 27 '20 at 10:12
  • 1
    _"This is so painful if the form has many many elements"_ `WinForms` consist of pain at 95%. If you really need a responsive and progressive app - switch to UWP or WPF until it's not too late. – vasily.sib Jan 27 '20 at 10:24

1 Answers1

1

I had a similar problem a couple of years ago where the switch to WPF would have been too time consuming for the company. Our solution involved setting up unified resizing code for forms and controls.

Some tips I can offer are:

  • Use a Panel based layout for everything.
  • Never position any control using absolute positioning.
  • FlowLayoutPanel works best for ordering your Panels to ensure consistent resizing.
  • Dock your root panel to your Form/UserControls.
  • Make sure you understand how Docking works. If you can generalise your resizing code; do it, as much as possible (writing separate resizing code for every Form will be a pain and not be maintainable).
demoncrate
  • 390
  • 2
  • 14