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. Add a list of System.Drawing.Color as a property

Add a list of System.Drawing.Color as a property

Scheduled Pinned Locked Moved C#
helpgraphicsquestionannouncement
5 Posts 3 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.
  • R Offline
    R Offline
    Rey9999
    wrote on last edited by
    #1

    Hello Everyone. I am creating a custom control. I need to add, amongst its properties, a bunch of lists. One of those is a list of System.Drawing.Color objects. I create the property as usual: private List<System.Drawing.Color> _Colors = new List<System.Drawing.Color>(); public List<System.Drawing.Color> Colors { get { return _Colors; } set { _Colors = value; } } This, however, seems not to get the things done quite right. Actually, I get this error: Cannot create an object of type 'System.Collections.Generic.List`1[[System.Drawing.Color, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]]' from its string representation '(Collection)' for the 'Colors' property. Do I need to add something to my code to have this property working? Thanks in advance - any help would be much appreciated. Rey9999

    ~~~ From Milano to The Hague, easy as it goes ~~~

    C G 2 Replies Last reply
    0
    • R Rey9999

      Hello Everyone. I am creating a custom control. I need to add, amongst its properties, a bunch of lists. One of those is a list of System.Drawing.Color objects. I create the property as usual: private List<System.Drawing.Color> _Colors = new List<System.Drawing.Color>(); public List<System.Drawing.Color> Colors { get { return _Colors; } set { _Colors = value; } } This, however, seems not to get the things done quite right. Actually, I get this error: Cannot create an object of type 'System.Collections.Generic.List`1[[System.Drawing.Color, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]]' from its string representation '(Collection)' for the 'Colors' property. Do I need to add something to my code to have this property working? Thanks in advance - any help would be much appreciated. Rey9999

      ~~~ From Milano to The Hague, easy as it goes ~~~

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      I think this means you have a control you can serialise, and you can't serialise a list of colors.

      Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      R 1 Reply Last reply
      0
      • R Rey9999

        Hello Everyone. I am creating a custom control. I need to add, amongst its properties, a bunch of lists. One of those is a list of System.Drawing.Color objects. I create the property as usual: private List<System.Drawing.Color> _Colors = new List<System.Drawing.Color>(); public List<System.Drawing.Color> Colors { get { return _Colors; } set { _Colors = value; } } This, however, seems not to get the things done quite right. Actually, I get this error: Cannot create an object of type 'System.Collections.Generic.List`1[[System.Drawing.Color, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]]' from its string representation '(Collection)' for the 'Colors' property. Do I need to add something to my code to have this property working? Thanks in advance - any help would be much appreciated. Rey9999

        ~~~ From Milano to The Hague, easy as it goes ~~~

        G Offline
        G Offline
        Giorgi Dalakishvili
        wrote on last edited by
        #3

        You are getting the error because 'Colors' is a class in .Net Framework. So just rename your property from 'Colors' to something else.

        Giorgi Dalakishvili #region signature my articles #endregion

        1 Reply Last reply
        0
        • C Christian Graus

          I think this means you have a control you can serialise, and you can't serialise a list of colors.

          Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

          R Offline
          R Offline
          Rey9999
          wrote on last edited by
          #4

          Thank you for the quick reply.

          ~~~ From Milano to The Hague, easy as it goes ~~~

          G 1 Reply Last reply
          0
          • R Rey9999

            Thank you for the quick reply.

            ~~~ From Milano to The Hague, easy as it goes ~~~

            G Offline
            G Offline
            Giorgi Dalakishvili
            wrote on last edited by
            #5

            You are welcome :)

            Giorgi Dalakishvili #region signature my articles #endregion

            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