且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Visual Studio Windows窗体控件在不同的计算机上重叠

更新时间:2021-12-19 07:23:09

如果正确设计UI布局,您将永远不会有不同屏幕的条件。这里的主要是避免任何绝对定位和尺寸。基本上,一切都应该停靠。请查看我过去的答案:

屏幕分辨率更改时,Zom Out出现故障 [ ^ ],

a基本代码示例:如何停靠按钮,以便它可以用表格调整 [ ^ ]。



-SA
You will never have this condition om different screens if you design the UI layout properly. Main thing here is to avoid any absolute positioning and sizing. Everything should be docked, basically. Please see my past answers:
Zom Out malfunctions when Screen resolution changes[^],
a rudimentary code sample here: how to dock button so that it can adjust with the form[^].

—SA


Windows窗体控件执行自动调整大小,这就是问题所在。你看到一切都变大了吗?这是因为屏幕不同......

他们自动调整以适应他们的内容 - 所以如果桌面上的字体在lappie上显示更大,那么在你的表单中分配给它的空间也是如此增加。不同的PC'可以有不同的默认字体大小...

你要求的是控件的大小保持不变,字体调整以适应控件 - 这不是不是在WinForms中发生,而是在WPF中发生,因此一种解决方案就是重写它。 (令人讨厌!)



更简单的解决方案可能是:在设计器中突出显示标签,然后按工具栏上的发送回按钮。
Windows forms controls do autosize, that''s the problem. You see how everything is bigger? It''s because teh screens are different...
They autosize to fit their content - so if a font on your desktop shows larger on the lappie, the the space allocated to it in your form also increases. And different PC''s can have different default font sizes...
What you are asking for is that the size of the controls stay the same, and the font adjusts to fit the controls - which doesn''t happen in WinForms, but does in WPF, so one solution is to re-write in that. (Nasty!)

A simpler solution might be: highlight your labels in the designer, and press the "send to back" button on the toolbar.