I have A Property in My own Custom Component with This Dictionary Type: ** Dictionary(Of Integer, RegistryDataItem) **
When I use that at designer Show this message at ErrorList:
Object of type 'System.Collections.Generic.Dictionary`2[System.Int32,StringProvider.RegistryDataItem]' cannot be converted to type 'System.Collections.Generic.Dictionary`2[System.Int32,StringProvider.RegistryDataItem]'.
How can I Correct this Problem and Make an Object Converter for my Dictionary?!
Protected RegistryDatasValue As New Dictionary(Of Integer, RegistryDataItem)
<ProviderType(ProvideTypes.RegistryData)>
<Browsable(True), RefreshProperties(RefreshProperties.All)>
<Editor(GetType(StringTableCollectionEditor), GetType(Drawing.Design.UITypeEditor))>
<DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)>
Public Property RegistryDatas() As Dictionary(Of Integer, RegistryDataItem)
Get
Return RegistryDatasValue
End Get
Set(ByVal value As Dictionary(Of Integer, RegistryDataItem))
RegistryDatasValue = value
End Set
End Property
<Serializable())>
Public Class RegistryDataItem
...
End Class
CodePudding user response:
I Find out How Correct this problem:
I Modify My Own Custom Editor with this changes:
I use TypeDescriptor to set property value. when use this way to change property value, Dictionary Items will be save at Designer.
Private Sub SetPropertyValue(Instance As Object, PropertyName As String, Value As Object)
Dim StringsDescryptor As PropertyDescriptor = TypeDescriptor.
GetProperties(Instance)(PropertyName)
StringsDescryptor.SetValue(Instance, Value)
End Sub