I'm well aware of the <System.ComponentModel.Browsable("False")>
attribute that I can apply to every property of a class. Is it possible to set the default value of the Browsable
attribute for all properties to False
?
The following code compiles and illustrates what I would like to achieve, but sadly it doesn't work as desired:
<Browsable(False)>
Public Class SomeClass
Public Property HiddenByDefaultProperty1 As Object
Public Property HiddenByDefaultProperty2 As Object
...
<Browsable(True)> Public Property BrowsableProperty As Object
End Class
To achieve what I want I would have to apply <Browsable(False)>
to all the properties I do not want to show in my DataGridView, which is a lot of code mess.
It would be great, if I would only have to specify <Browsable(True)>
for the properties I want to show. But: is it possible?
No, I don't think this is possible using the browsable attribute. However, you can control which properties the DataGridView will bind to by implementing the ICustomTypeDescriptor interface.
Model
C#:
VB.Net:
DataGridView:
C#:
VB.Net:
PropertyGrid:
C#:
VB.Net: