如何让 WinForm 设计器完全忽略自定义控件上的属性? [英] How do I get the WinForm Designer to totally ignore a property on a custom control?

查看:28
本文介绍了如何让 WinForm 设计器完全忽略自定义控件上的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这一定是一个常见问题,但我找不到重复的问题!

有很多不同的属性可以控制 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.

我正在寻找:

  • 设计器不在网格中显示属性
  • 设计器未读取属性值
  • 设计器未将属性设置为默认值
  • 例如设计师表现得好像该属性不存在.
  • 如果在添加属性之前设计者已经完成了上述之一(很难!)

背景.

给我带来问题的代码是:

The code that is giving me the problem is:

this.eventListControl.FilterSets = 
   ((SystList<FilterSet>)(resources.GetObject("eventListControl.FilterSets")));

FilterSets 属性不应该被 winforms 设计者触及;它现在不可序列化,并且每次使用 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 设计器完全忽略自定义控件上的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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