简体   繁体   English

如何使 Winforms 应用程序具有透视性和响应性,就像网页一样?

[英]How to make a Winforms App Perspective and Responsive, like a web page?

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 ?如何使 Windows 窗体应用程序具有透视性,以使其像所有元素都可调整大小的网页一样?

I mean that it should fill in all screen sizes , laptops and desktops.我的意思是它应该填充所有屏幕尺寸、笔记本电脑和台式机。

I have tried everything but none is working v,我已经尝试了一切,但没有一个工作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...如果 Windows 窗体有很多元素,你必须在所有控件中创建所有属性,当你更改一个属性时,也许你必须再次更改另一个属性,一次又一次......

I am looking for something like when we make a Web Page , its easier and much more elegant.我正在寻找类似的东西,当我们制作一个Web Page ,它更容易和更优雅。

I had a similar problem a couple of years ago where the switch to WPF would have been too time consuming for the company.几年前,我遇到了类似的问题,在这种情况下,切换到 WPF 对公司来说太耗时了。 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. FlowLayoutPanel 最适合订购您的面板以确保一致的调整大小。
  • Dock your root panel to your Form/UserControls.将您的根面板停靠到您的 Form/UserControls。
  • Make sure you understand how Docking works.确保您了解Docking 的工作原理。 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).尽可能多地这样做(为每个 Form 编写单独的调整大小的代码会很痛苦并且不可维护)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM