简体   繁体   English

如何使WinForm Designer完全忽略自定义控件上的属性?

[英]How do I get the WinForm Designer to totally ignore a property on a custom control?

This must be a FAQ, but I can't find a duplicate question! 这必须是一个常见问题解答,但我找不到重复的问题!

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. 有许多不同的属性可以控制WinForm设计器使用自定义控件上的属性,在这种情况下,我永远都不清楚应该使用哪种属性。

I am looking for: 我在寻找:

  • Designer does not show property in grid 设计器未在网格中显示属性
  • Designer does not read value of property 设计器不读取属性的值
  • Designer does not set property to default value 设计器未将属性设置为默认值
  • Eg Designer behaves as if the property was not there . 例如,Designer的行为就好像该属性不存在
  • Designer does not complain if it has already done one of the above before the attributes were added (hard!) 在添加属性之前,Designer不会抱怨它是否已执行上述操作之一(很难!)

Background. 背景。

The code that is giving me the problem is: 给我的问题的代码是:

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

The FilterSets property should never have been touched by the winforms designer; WinForms设计人员绝对不应接触FilterSets属性。 it is now not Serializable and MsDev falls over every time a form that used the eventListControl is changed! 现在它无法序列化,并且每次更改使用eventListControl的表单时,MsDev都会掉落!

I think you can use [Browsable (false)] and [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] 我认为您可以使用[Browsable (false)][DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]

The second attribute prevents the property from appearing in InitializeComponent 第二个属性阻止该属性出现在InitializeComponent

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Winform Designer 使用自定义控件生成名称错误 - Winform Designer generated name bug with custom control 从自定义控件的另一个属性获取设计器中设置的属性值 - Get the property value set in the Designer from another property of a Custom Control 如何在WinForm的控件设计器中使用鼠标按比例调整控件的大小? - How to proportionally resize a control with the mouse within WinForm's control designer? 如何告诉设计师我的自定义winforms控件有一个固定的高度? - How do I tell the designer that my custom winforms control has a fixed height? 如何创建更新设计器的.NET Winforms自定义控件? - How do you create a .NET winforms custom control that updates the designer? 如何获取winform的GUI线程? - How do I get the GUI thread of winform? 如何在自定义控件的属性网格中获取OpenFileDialog? - How can I get an OpenFileDialog in a custom control's property grid? 如何在不禁用现有设计器功能的情况下将设计器动词添加到控件? - How do I add a designer verb to a control without disabling existing designer functionality? 如何在设计时创建可以订阅另一个 WinForm 控件的 C# 属性? - How do you create a C# property that can subscribe to another WinForm control at design time? 如何在WinForms自定义控件的控件设计器属性中添加组合框? - How can I add a combobox in control designer properties for a WinForms custom control?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM