I created a class that inherits button in win forms How can i create a Browsable property with type dictionary ?
here is my code but i didn't find it in properties menu vb.net
<Browsable(True)>
Property Set_ddn() As Dictionary(Of TextBox, String)
Get
Return ddn
End Get
Set(ByVal value As Dictionary(Of TextBox, String))
ddn = value
End Set
End Property
how can i make it browsable ? or what should i use instead of dictionary?
or another solution
i found the answer here (C#) https://stackoverflow.com/a/42829336/1543991
rewrite code for
vb.net
You should write your own type descriptor by deriving from
CustomTypeDescriptor
or implementingICustomTypeDescriptor
. Here is an example:MyPropertyDescriptor
Provide a custom description for a property. Here I override Attributes property to provide a new list of attributes for property. For example I check if the property has
[Category("Extra")]
, I also added a[Browsable(false)]
to its attribute collection.MyTypeDescriptor
Used to provide a list of custom property descriptors for a type.
MyTypeDescriptionProvider
Used to connect
MyTypeDescriptor
to a class usingTypeDescriptionProvider
attribute.MySampleClass
Contains a property decorated with [Category("Extra")]. So
Property2
will not be visible in property grid. (In visual studio or collection editor or even run-time property grid)MyComplexComponent
Contains a collection of
MySampleClass
. So you can see behavior ofMySampleClass
in collection editor.