Hi,
I have discovered an anomaly … settting Button.BackColor only works the first time …
private void button1_Click(object sender, EventArgs e)
{
button1.BackColor = Color.FromName(“#CCCCCC”);
}
private void button2_Click(object sender, EventArgs e)
{
button1.BackColor = Color.FromName(“#64e764”);
}
After opening the form, clicking button1 goes gray, clicking button2 then has no affect.
After opening the form, clicking button2 goes green, clicking button1 then has no affect.
Cheers,
Neil.
Many thanks Frank. That has fixed it.
Still … some interesting behaviors, the button BackColor assignment worked the first time with Color.FromName(#) but not subsequently, and other controls (Labels, Checkboxes, DataGridViewCells that I have spotted) work OK all the time.
Regardless, I’ve changed all # colors to ColorTranslator.FromHtml now, thanks.
Cheers,
Neil
Hi Neil,
thanks for posting this, but it´s not an anomaly in Wisej.
Color.FromName is only for known names:
https://msdn.microsoft.com/en-us/library/system.drawing.color.fromname(v=vs.110).aspx
If you want to use it for HTML codes you have to use System.Drawing.ColorTranslator.
If I replace your code with
ColorTranslator.FromHtml(….) it works as expected.
Hope that helps.
Best regards
Frank
Please login first to submit.