Hi Chris,
I think the BrowsableAttribute class is only useful if I have control on the
class coding. The object assigned to propertygrid is an object returned by
a .NET method so I have no direct way to change the attribute. Based on
what I have found so far, I think it is possible to change the attribute of
the existing object using reflection but I need to learn reflection first if
that is the only way.
Can you elaborate about the adapter object way?
I simply meant create another class that acts as a container to the
class you want to limit the properties for and then only expose the
properties you want:
Public Class AdapaterClass
'classToLimit has lots of properties, but we only want some of
them
'visible in the PropertyGrid
Private _instance As classToLimit
Public Sub New(object As classToLimit )
_instance = object
End Sub
Public Property Property1() As String
Get
Return _instance.Property1
End Get
Set
_instance.Property1 = Value
End Set
End Property
Public Property Property2() As String
Get
Return _instance.Property2
End Get
Set
_instance.Property2 = Value
End Set
End Property
<Browsable(False)> _
Public ReadOnly Property Instance() As classToLimit
Get
Return _instance
End Get
End Property
End Class
Then you add an instance of the AdapterClass to the PropertyGrid.
I think VisualHint's suggestion is probably the way to go, but this
method, at least, is easy.
Chris