How do I hide some of the default control properties at design-time (C#)?

后端 未结 4 780
情深已故
情深已故 2021-01-04 10:56

I have a custom control that I made. It inherits from System.Windows.Forms.Control, and has several new properties that I have added. Is it possible to show m

4条回答
  •  孤街浪徒
    2021-01-04 11:36

    You could either override them (if they can be overriden) and apply the Browsable attribute, specifying false, or create a new version of the property and apply the same attribute (this second approach doesn't always appear to work so YMMV).

    Also, you can use a custom TypeConverter for your type and override the GetProperties method to control what properties get displayed for your type. This approach is more robust to the underlying base classes changing but can take more effort, depending on what you want to achieve.

    I often use a combination of the Browsable attribute and a custom TypeConverter.

提交回复
热议问题