在Windows窗体控件中调整大小以及调整窗体大小

在Windows窗体控件中调整大小以及调整窗体大小

本文介绍了在Windows窗体控件中调整大小以及调整窗体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的C#Windows Forms应用程序中有一些控件(组框,表格,GridView等),我想根据屏幕的宽度/高度来缩放它们.

I have a few controls (group boxes, tables, gridview, etc.) in my C# Windows Forms application, and I would like to scale them based on screen width/height.

例如,屏幕开始于640x480,然后最大化到1920x1200.

For example, the screen starts at, let's say, 640x480 and then it gets maximized to 1920x1200.

我希望能够增加控件的宽度/高度,以便在调整窗口大小后看起来完全一样.

I want to be able to increase the width/height of the controls so they look the exact same after the window gets re-sized.

没有手动设置每个width/height属性的最佳方法是什么?

What is the best way to do that, without setting every width/height property manually?

推荐答案

代替指定宽度和高度,可以使用AnchorDock属性使控件根据其包含的元素缩放.

Instead of specifying width and height, you can use the Anchor and Dock properties to have controls scale based on their containing elements.

或者,您可以使用 TableLayoutPanel FlowLayoutPanel 来安排控件.

Alternatively, you can use TableLayoutPanel or FlowLayoutPanel to arrange your controls.

这篇关于在Windows窗体控件中调整大小以及调整窗体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 02:10