Dovberman
asked on
How to set the backcolor of a control
The following statement sets the BackColor to a named color.
celHole2.BackColor = System.Drawing.Color.Green
How do I set the BackColor to a Hex color? ie. Hex={00,99,33} RGB
celHole2.BackColor = System.Drawing.Color.{00,9
Thanks,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Is something not clear?
eg.
this.listBox1.BackColor = Color.FromArgb( Convert.ToInt16("FF", 16), Convert.ToInt16("00", 16), Convert.ToInt16("00", 16));
or this with your colour
this.listBox1.BackColor = Color.FromArgb( Convert.ToInt16("00", 16), Convert.ToInt16("99", 16), Convert.ToInt16("33", 16));
eg.
this.listBox1.BackColor = Color.FromArgb( Convert.ToInt16("FF", 16), Convert.ToInt16("00", 16), Convert.ToInt16("00", 16));
or this with your colour
this.listBox1.BackColor = Color.FromArgb( Convert.ToInt16("00", 16), Convert.ToInt16("99", 16), Convert.ToInt16("33", 16));
ASKER
Thank you.
Don't forget - the comment from pratima_mcs doesn't actually work for what you requested (hex values for the colours). Try it with another valid hex value
System.Drawing.Color.FromA rgb(FF,99, 33) and it won't even compile.
System.Drawing.Color.FromA
ASKER
I used celHole1.BackColor = System.Drawing.Color.FromA rgb(00, 99, 33);
This works.
I did not notice the System.Drawing.Color.FromA rgb(FF,99, 33) statement from Pratima MCS.
The statement from Pratima MCS that I used successfully was System.Drawing.Color.FromA rgb(00, 99, 33);
If I miscalculated the credits, please ask the monitor to make the correction.
Thank you,
This works.
I did not notice the System.Drawing.Color.FromA
The statement from Pratima MCS that I used successfully was System.Drawing.Color.FromA
If I miscalculated the credits, please ask the monitor to make the correction.
Thank you,
>>celHole1.BackColor = System.Drawing.Color.FromA rgb(00, 99, 33);
That is NOT using those hex values you specified, they are the int values. To use those hex values you must convert them to integer values - see my comments.
credits - I'll leave it in your hands if you want to ask a moderator to change things. I posted my later comment in case you didn't realise the mistake that a hex value of 99 is not the same as an integer value of 99.
That is NOT using those hex values you specified, they are the int values. To use those hex values you must convert them to integer values - see my comments.
credits - I'll leave it in your hands if you want to ask a moderator to change things. I posted my later comment in case you didn't realise the mistake that a hex value of 99 is not the same as an integer value of 99.
Convert.ToInt16("80", 16); //where the string part is the hex value