Results 1 to 1 of 1

Thread: DesignerSerializationVisibility

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2004
    Posts
    14

    Angry DesignerSerializationVisibility

    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:
    1. Me.m1.Colours.back = System.Drawing.SystemColors.Control
    2. Me.m1.Colours.clientback = System.Drawing.SystemColors.Control
    3. Me.m1.Colours.disabledback = System.Drawing.Color.LightBlue
    4. 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:
    1. 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:
    1. Me.m1.Colours.#back = System.Drawing.SystemColors.Control
    2. Me.m1.Colours.#clientback = System.Drawing.SystemColors.Control
    3. Me.m1.Colours.#disabledback = System.Drawing.Color.LightBlue
    4. Me.m1.Colours.#disabledfore = System.Drawing.Color.DarkGray

    thanks in advance
    Last edited by Bitem2k; Apr 3rd, 2005 at 08:48 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width