views:

386

answers:

1

Hi All,

I want to add attributes (like Browsable(false)) dynamically while displaying in the grid. Scenario is that I have a custom class with some public properties. However, I dont want all of the public properties to be displayed in the UI. Is there a way out?

I tried using TypeDescriptor. However, it works only at the type level and not at the property level. I couldn't find any help on how to use it at property-level.

Any pointers will be highly appreciated.

+1  A: 

I have been working in this same area for the past few days. Long story short, I came to the conclusion this is not possible.

Is the reason you are attempting to apply attributes at runtime because you dont want to mix "UI" code with your custom classes?

If that is the case, the BrowsableAttribute is a member of the ComponentModel (http://msdn.microsoft.com/en-us/library/system.componentmodel.aspx) and is not UI related in the same sense as WinForms.

Karl

Karl