Windows 窗体设计器破坏窗体布局 [英] Windows Forms Designer destroys form layout

查看:39
本文介绍了Windows 窗体设计器破坏窗体布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天早上,我在 Visual Studio 的 Windows 窗体设计器中偶然发现了一个奇怪的问题.我有一个表格,现在可以使用大约一个月而没有更改.在应用程序中看起来像这样:

This morning I stumbled over a weird issue in Visual Studio's Windows Forms designer. I have a form which worked for about a month now without changes. It looks like this in the application:

(文本变得不可读,因为我不完全确定此处的法律含义).

(text made unreadable because I'm not entirely sure of the legal implications here).

从今天开始,显然(我想我昨天在设计器中打开了表单没有问题)它在设计器中看起来像这样:

Now starting today, apparently (I think I had the form open in the designer yesterday without problems) it looks like this in the designer:

查看差异,每个控件(或几乎每个控件——标签不受影响,但这可能与 AutoSize 相关)的宽度为 311 像素.设计人员弄乱文件后,如下所示的行在整个文件中很常见:

Looking at the diff, every control (or nearly every one—labels were not affected, but that may be related to AutoSize) got a width of 311 pixels. Lines like the following are common throughout the file after the designer messed with it:

this.panel1.Size = new System.Drawing.Size(311, 24);

无论那个值来自哪里.此外,一个标签得到了有趣的文本潐玱⼠倠獯莹潩㩮攀瑵慲ⱬ"(它的原始字节没有任何意义).

Wherever that value comes from. Furthermore one label got the interesting text "潐瑲⼠倠獯瑩潩㩮攀瑵慲ⱬ" (it doesn't make any more sense in its raw bytes).

当我没有在设计器中打开表单时,没有什么不好的事情发生,项目甚至在文件未触及的情况下构建,并且在运行程序时看起来很好.但是打开设计器会触发设计器生成的代码中的上述更改,并且这些更改在编译时会持续存在(显然).

When I don't open the form in the designer nothing bad happens, the project even builds when the files are untouched and it looks fine when running the program. But opening the designer triggers aforementioned changes in the designer-generated code and those changes persist when compiling (obviously).

在同事的机器上根本不会发生这种情况(但他无法在不崩溃 VS 的情况下打开数据集,所以也许这里的两种设置都有点奇怪......).

On a co-worker's machine this doesn't happen at all (yet he can't open datasets without crashing VS, so perhaps both setups here are a little weird ...).

我真的很想知道这里发生了什么.有什么想法吗?

I seriously wonder what's going on here. Any ideas?

预计到达时间:一旦设计器开始调整大小,我就无法更改设计器中控件的大小.调整大小只会导致一些视觉伪像,就好像控件调整了大小,但在检查时它仍然是 311 px 宽度.

ETA: I can't change size of the controls in the designer once it went on its resizing rampage. Resizing merely causes some visual artifacts as if the control was resized but it's still at 311 px width when checking.

ETA 2: 够奇怪的:打开设计器(导致损坏,到目前为止一切顺利),然后使用 AnkhSVN 进行待处理的更改并恢复对文件的所有更改也会恢复损坏.即使在设计器中,表单看起来也应该如此.直到我关闭并重新打开它.

ETA 2: Weirdly enough: Opening the designer (causes corruption, so far so good), then going into pending changes with AnkhSVN and reverting all changes to the files reverts the corruption too. The form looks like it should even in the designer. Until I close and re-open it again.

推荐答案

我找到了罪魁祸首.我最近安装了 RockScroll.虽然我无法将该行为直接链接到 RockScroll,但我注意到某些表单的滚动条替换了它.并且该表单上的控件无缘无故地更改了大小.

I found the culprit. I recently installed RockScroll. And while I couldn't directly link that behavior to RockScroll I noticed that some forms had the scrollbar replacement of it drawn over them. And controls on that form changed size without reason.

卸载RockScroll,它解决了问题.无论如何,感谢您的所有投入.

Uninstalled RockScroll and it solved the problem. Thanks for all the input, anyway.

这篇关于Windows 窗体设计器破坏窗体布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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