Windows Forms resolution problem

后端 未结 3 1360
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-13 14:12

I have developed a 1024 *780 resolution screen in Windows Forms, but some say that it does not fit properly at higher resolutions. Is there any way to handle this?

相关标签:
3条回答
  • 2021-01-13 14:29

    You can use anchor property of item, and autoScaleMode property of form set it equals 'None'.

    0 讨论(0)
  • 2021-01-13 14:36

    My recommendation is not so much to "make it look the same" on all screens, but rather to design the GUI so it scales up and down more gracefully. Layout managers, docking, and anchors are your friends in Winforms. The TableLayoutPanel is quite useful for this sort of thing. Splitters also help...

    Finally, this is one of those problems that WPF sets out to solve. WPF makes extensive use of layout managers. It feels much more like Java or GTK than Winforms or even VB (old school VB).

    0 讨论(0)
  • 2021-01-13 14:50

    This is the sort of thing that makes you say "there's got to be a better way."

    My solution for this one time was to declare a global ScalingFactor variable that was tied to the current screen resolution. Then, the sizes of every visual element were multiplied by that factor.

    So, if I designed my form for resolution A, and resolution B is 1.2x larger, the width of window A will be with * 1.2, the fonts will be fontSize * 1.2, the textbox dimensions will be dimensions * 1.2.

    Not fun.

    There may be 3rd party tools that you can buy and will perform this scaling.

    One other thing to check before you run down any of these roads is whether it is actually the screen resolution or the dpi settings that are causing it to look bad. Usually a higher resolution will only make it look smaller, but an atypical dpi, such as when the user selects "large fonts" will wreak havoc.

    0 讨论(0)
提交回复
热议问题