How do I get the WinForm Designer to totally ignore a property on a custom control?(如何让 WinForm Designer 完全忽略自定义控件上的属性?)
问题描述
这一定是常见问题解答,但我找不到重复的问题!
有很多不同的属性可以控制 WinForm 设计器对自定义控件的属性所做的事情,我一直不清楚在这种情况下应该使用哪个.
There are lot of different attributes that control what the WinForm Designer does with properties on a custom control, I am never clear on the one I should use in this case.
我正在寻找:
- 设计器不在网格中显示属性
- 设计器未读取属性值
- 设计器未将属性设置为默认值
- 例如设计器的行为就像属性不存在一样.
- 如果设计师在添加属性之前已经完成了上述任一操作(很难!)
背景.
给我问题的代码是:
this.eventListControl.FilterSets =
((SystList<FilterSet>)(resources.GetObject("eventListControl.FilterSets")));
Winforms 设计者不应该触及FilterSets 属性;它现在不可序列化,并且每次更改使用 eventListControl 的表单时,MsDev 都会崩溃!
The FilterSets property should never have been touched by the winforms designer; it is now not Serializable and MsDev falls over every time a form that used the eventListControl is changed!
推荐答案
我觉得你可以使用 [Browsable (false)]
和 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
I think you can use [Browsable (false)]
and [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
第二个属性防止属性出现在InitializeComponent
The second attribute prevents the property from appearing in InitializeComponent
这篇关于如何让 WinForm Designer 完全忽略自定义控件上的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何让 WinForm Designer 完全忽略自定义控件上的属性?


基础教程推荐
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01