DesignerSerializationVisibility
:afrog: :afrog: :afrog: :duck: :duck: Hi ive built a custom menubar control that uses a strongly typed Hashtable to store the colours needed to paint the control, and i have made this collection available to the proprty grid in vs.net by implementing ICustomTypeDescriptor on the collection and also by creating a class that inherits PropertyDescriptor.
My problem is that i have set the designerserializationvisibilityattribute to content, but when it serialises the settings it does it incorrectly
i.e
these are the serialized settings created by vs.net, which appears to be treating the Hashtable members like they were actual properties.
VB Code:
Me.m1.Colours.back = System.Drawing.SystemColors.Control
Me.m1.Colours.clientback = System.Drawing.SystemColors.Control
Me.m1.Colours.disabledback = System.Drawing.Color.LightBlue
Me.m1.Colours.disabledfore = System.Drawing.Color.DarkGray
Now the problem with these is that instead of a fullstop in between Colours and the Hashtable item there should be either a ( for vb or a [ for c# and then the item name in quotes
VB
VB Code:
Me.m1.Colours("DisabledFore") = Color
C#
Code:
this.m1.Colours["DisabledFore"] = Color;
Does anyone have any ideas how to get vs to output this correctly?
I have found some code that i can add to the Constructor of the propertyDescriptor:
Code:
public ColourCollectionPropertyDescriptor(cb.WinForms.cbColourCollection Colours,string Name ):base("#" + Name.ToString(),null)
{
colours = Colours;
name = Name;
}
the extra base bit changes the name of the item see the below.
VB Code:
Me.m1.Colours.#back = System.Drawing.SystemColors.Control
Me.m1.Colours.#clientback = System.Drawing.SystemColors.Control
Me.m1.Colours.#disabledback = System.Drawing.Color.LightBlue
Me.m1.Colours.#disabledfore = System.Drawing.Color.DarkGray
thanks in advance