Visual Studio Designer 总是试图改变我的控制 [英] Visual Studio Designer is always trying to change my control

查看:28
本文介绍了Visual Studio Designer 总是试图改变我的控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个有点复杂的 UserControl,而 Visual Studio 2008 在使用它时给我带来了相当无害的烦恼.每次我用设计器打开控件时,它都会决定立即更改设计器设置的一些无害值——即 Size 属性的初始化.如果我保存这些更改,关闭并重新打开,它几乎总是会决定我的控件的另一个组件需要更改其初始大小,直到无限.幸运的是,这些更改是无害的,因为我在任何地方都使用自动调整大小,但这很烦人.我还不清楚从哪里开始找出问题所在,我现在唯一的想法是每次打开控件时设计器都会将自动调整大小的结果分配回初始大小字段.关于原因/修复的任何想法?

I have a somewhat complex UserControl, and Visual Studio 2008 is giving me a rather harmless annoyance when working with it. Every single time I open the control with the Designer, it decides to immediately change some of the harmless values set by the designer - namely the initialization of Size properties. If I save those changes, close, and reopen, it almost invariably ends up deciding another component of my control needs its initial size changed, ad infinitum. Luckily these changes are harmless since I'm using automatic sizing everywhere, but this is quite annoying to work with. I haven't the foggiest on where to start figuring out what's going wrong, my only thought right now is that the Designer is assigning the results of auto-sizing back into the initial size fields every time I open the control. Any ideas on causes/fixes?

另外,我正在使用应用程序设置来保存跨应用程序运行的某些可调整大小的子组件的大小,但我真的希望设计器足够聪明,能够理解它应该永远是使用默认值.

Also, I am using Application Settings to save sizes of certain resizable child components across runs of the application, but I really hope the Designer is smart enough to understand that it should only ever be using the defaults.

推荐答案

也许能帮上忙:
我注意到如果您插入一个自定义 UserControl,FormDesigner(没有 WPF、没有 Web 等)会出现奇怪的行为.
其他控件(GroupBox、EditBox、ComboBox)的大小随机变化(对我来说发生在宽度上).
选择调整大小的控件似乎是随机的,但是在重新启动 vs2010 时它总是相同的.如果删除并重新插入,设计者会选择不同的控件来随机调整大小...

我将 UserControl 的属性 AutoScaleMode 从Font"更改为Inherit",但它没有再次发生.

Maybe it can help:
I noticed that FormDesigner (no WPF, no Web etc) has a strange behaviour if you insert one custom UserControl.
There is a random change of other controls (GroupBox, EditBox, ComboBox) size (to me happened with width).
The controls choosen to resize seems to be random, but across restarting of vs2010 it is always the same. If deleted and reinserted, the designer chooses a different control do randomly resize...

I changed the property AutoScaleMode of my UserControl from "Font" to "Inherit" and it did not happen again.

这篇关于Visual Studio Designer 总是试图改变我的控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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