I want to set the color of my control using a string variable with a value of say “Blue”.
Normally you would set it:
Label1.Color = Color.Blue;
But now I want to replace Color.Blue with the value that is in my string variable, like:
Label1.Color = sColor; // sColor = “Blue”
But I get the error: Cannot convert type ‘string’ to “System.Drawing.Color”
Any help appreciated.
Use the Color.FromName function to pass in a string: