Archive for the ‘Colors’ Category
Convert color to string
To convert a color to a string use the ColorConverter class but this can be access through TypeConverter class;
-
Dim myColor as Drawing.Color = Color.Red
-
-
Dim clor As System.ComponentModel.TypeConverter = System.ComponentModel.TypeDescriptor.GetConverter(myColor)
-
dim ColorName as string
-
-
ColorName = clor.ConvertToString(Color.Red)
Convert color from string
To convert a color from a string use the ColorConverter class but this can be access through TypeConverter class;
-
Dim myColor as Drawing.Color
-
-
Dim clor As System.ComponentModel.TypeConverter = System.ComponentModel.TypeDescriptor.GetConverter(GetType(Drawing.Color))
-
-
myColor = clor.ConvertFromString("Blue")
MyColor variable is now ready to use.