Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
462 views
in Technique[技术] by (71.8m points)

.net - 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.

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
  • E.g. Designer behaves as if the property was not there.
  • Designer does not complain if it has already done one of the above before the attributes were added (hard!)

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; it is now not Serializable and MsDev falls over every time a form that used the eventListControl is changed!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I think you can use [Browsable (false)] and [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]

The second attribute prevents the property from appearing in InitializeComponent


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...