Chris Laplante
Chris Laplante

Reputation: 29668

How to isolate a set of properties for use with a PropertyGrid?

I have several classes that inherit from WinForm UI controls. They have been extended with extra properties which I need to be editable in a property grid control. The problem is, assigning an instance of this object to the property grid also displays the UI properties, like Color, Text, Dock, etc. What would be the best way of isolating the specific properties so that these UI properties do not show up?

Thank you for your advice,

Upvotes: 1

Views: 206

Answers (2)

Marc Gravell
Marc Gravell

Reputation: 1063774

You my be able to override the properties you don't want and add [Browsable(false)]. Other options:

The BrowsableAttributes would be my first stab.

Upvotes: 2

Andrew Kennan
Andrew Kennan

Reputation: 14157

You could provide your own TypeDescriptor for your classes that only expose the properties you want editable.

Alternatively, if that's way too much work or the property grid is one in your own app, rather than the winforms designer one, you could create your own proxy classes that only expose the extra properties.

Upvotes: 1

Related Questions