Add a list of System.Drawing.Color as a property
-
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 ~~~
-
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 ~~~
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 )
-
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 ~~~
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
-
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 )
-
You are welcome :)
Giorgi Dalakishvili #region signature my articles #endregion