自定义控件的属性设置在设计时不会保留 [英] Property settings of custom control are not persisted at design-time

查看:68
本文介绍了自定义控件的属性设置在设计时不会保留的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我有一个关于设计时问题的问题.
在VB.net 2010中,我有一个自定义控件,该用户的属性由另一个自定义控件通过UITypeEditor(通过代码)设置. 进行了更改,但是IDE不会保留这些设置.这意味着在表单选项卡中没有星号表示该表单已被标记为脏,因此在我存储项目时将其保存.
仅当我手动对表单进行其他更改时,星号才会出现(肮脏的表单标记),并且我的属性设置会保留.

有人知道如何解决这个问题吗?
有没有一种方法可以在设计时通过代码设置脏表单标记?
有没有一种方法可以通知IDE某个控件已进行更改,以将其容器窗体标记为脏?

在此先感谢您.

Hello,

I have a question regarding a design-time problem.
In VB.net 2010 I have a custom control who''s properties are being set by another custom control through a UITypeEditor (through code).
The changes are made, however the IDE does not persist these settings. Meaning that there does not appear a star in the form tab to indicate that the form has been marked dirty and hence is saved when I store the project.
Only when I manually make other changes to the form the star appears (dirty form marker), and my property settings are persisted.

Does anyone know how to solve this problem?
Is there a way to set the dirty form marker at design time through code ?
Is there a way to notify the IDE that changes have been made to a certain control, in order to mark it''s container form as dirty?

Thanks in advance.

推荐答案

您可能想在控件属性上缺少想要设计人员为其编写代码的
You''re probably missing the
<DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)>

属性.

将此属性添加到您想要设计时值支持的每个属性中,然后设计器将为其生成代码.

attribute on your controls properties that you want the designer to write code for.

Add this attribute to every property that you want design-time value support for and the designer will generate code for it.


这篇关于自定义控件的属性设置在设计时不会保留的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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