Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Persisting Property of userdefined Collection type.

Persisting Property of userdefined Collection type.

Scheduled Pinned Locked Moved C#
designhelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zorifila
    wrote on last edited by
    #1

    Hi, I have exposed a property in a UserControl. The Property is of Collection type. ( Collection of my Userdefined type). When I use this Control in a Form, the Forms Designer allows me to Edit the property (MyValues) using the Default Collection Editor UI. But the Changes made to the Collection are not persisted in the Form code by the Forms Designer.

    //------------------------------------
    class MyControl : UserControl
    {

    MyTypeCollection m_values = new MyTypeCollection();

    public MyTypeCollection MyValues
    {
    get
    {
    return m_values ;
    }
    set
    {
    m_values = value;
    }
    }

    }

    //------------------------------------

    class MyTypeCollection : CollectionBase
    {
    Add(){...}
    Remove(){...}
    }

    //------------------------------------

    class MyType
    {
    int i;
    bool b;

    public int XXX
    {
    get
    {
    return i;
    }
    set
    {
    i= value;
    }
    }

    public bool YYY
    {
    get
    {
    return b;
    }
    set
    {
    b= value;
    }
    }

    }

    How can I make the Forms Designer generate code for the Collection Modified at Design time. Please someone Help me... Zor

    X 1 Reply Last reply
    0
    • Z zorifila

      Hi, I have exposed a property in a UserControl. The Property is of Collection type. ( Collection of my Userdefined type). When I use this Control in a Form, the Forms Designer allows me to Edit the property (MyValues) using the Default Collection Editor UI. But the Changes made to the Collection are not persisted in the Form code by the Forms Designer.

      //------------------------------------
      class MyControl : UserControl
      {

      MyTypeCollection m_values = new MyTypeCollection();

      public MyTypeCollection MyValues
      {
      get
      {
      return m_values ;
      }
      set
      {
      m_values = value;
      }
      }

      }

      //------------------------------------

      class MyTypeCollection : CollectionBase
      {
      Add(){...}
      Remove(){...}
      }

      //------------------------------------

      class MyType
      {
      int i;
      bool b;

      public int XXX
      {
      get
      {
      return i;
      }
      set
      {
      i= value;
      }
      }

      public bool YYY
      {
      get
      {
      return b;
      }
      set
      {
      b= value;
      }
      }

      }

      How can I make the Forms Designer generate code for the Collection Modified at Design time. Please someone Help me... Zor

      X Offline
      X Offline
      xicoloko
      wrote on last edited by
      #2

      Zor, Try to add the following attribute to your property: [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] Cheers, - xico -

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups