我的Windows窗体在构建时不断缩小/调整大小 [英] My Windows Form keeps on shrinking/resizing on build

查看:83
本文介绍了我的Windows窗体在构建时不断缩小/调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理Windows Forms项目.它包含一个选项卡控制器,该控制器具有多个页面,每个页面上都有多个控件.

I am working on a Windows Forms project. It contains a tab controller with multiple pages and multiple controls on each.

似乎相对较新,在对表单进行了某些更改之后,每次我构建并运行该解决方案时,表单都会调整大小/缩小.

It appears that relatively recently, after some form changes, that each time I build and run the solution the form resizes/shrinks.

因此,如果我将表单高度的大小设置为768,则单击开始"以生成并运行它时,实际上我可以瞥见它在调整过程中会自动调整大小,然后表单加载时间缩短了21像素.而不是其生成时的高度值.

So if I set the size of the form height to 768, once I click 'Start' to build and run it, I can actually catch a glimpse of it resizing itself during the process and then the form loads 21 pixels shorter than the height value it was at build for.

如果我随后继续构建并运行我的项目,则表单每次将减少21像素,从而使每次构建都变得越来越小.

If I then keep building and running my project, the form will decrease by 21 pixels each time, making it smaller and smaller with every build.

我们认为它可能是在将"DataGridView"控制器添加到其中一个选项卡时引入的,但是我们尚未证明是否是这种情况.

We think it might have been introduced when we added the 'DataGridView' controller to one of the tabs, but we have yet to prove if that's the case.

是否有发生这种情况的原因,该怎么办? 为什么要在构建运行时调整自身大小?

Is there a reason why this would be happening, and what could be doing this? Why would it resize itself during build run time?

推荐答案

这是一个令人讨厌的错误,我自己也经历过类似的行为.但是,也许有一些解决方法,但是可能会被警告,这些解决方法可能有帮助也可能无济于事,听起来有些琐.

This is an annoying bug, and I have suffered similar behavior myself. However, there maybe a couple of workarounds, however be warned though, these may or may not help and sound a little hacky.

如果您的控件未对接,则对接可能会有所帮助.

If your control isn't docked, docking may help.

您也许可以更改DPI设置来消除此问题,即:

You might be able to change your DPI settings to eliminate the problem, i.e.:

显示属性设置标签→高级.在 Advanced 对话框中,我更改了"DPI设置"从(120 dpi)到 Normal (96 dpi).

Display PropertiesSettings tab → Advanced. In the the Advanced dialog I changed the "DPI Settings" from Large (120 dpi) to Normal (96 dpi).

这可能是由于AutoScaleMode属性所致.您的表单设计时的DPI或字体设置可能与Windows显示设置中的设置不同.尝试在您的表单和有问题的控件中将AutoScaleMode属性设置为无",它们将不再自动调整大小.

This is maybe due to AutoScaleMode-property. Your forms may have been designed with a different DPI or font settings than you have now in Windows display settings. Try setting the AutoScaleMode-property to None in your form and offending controls, and they won't be automatically re-sized anymore.

这篇关于我的Windows窗体在构建时不断缩小/调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆