I have a color dialog in visual studio, I am currently using this c# code to display the color dialog and set the color to a panel:
private void ColorButton_Click(object sender, EventArgs e)
{
if (colorDialog1.ShowDialog() == DialogResult.OK)
{
ColorPanel.BackColor = colorDialog1.Color;
}
}
How could I set a label to the hexadecimal color code of the color picker?
You can try this
ARGB
(Alpha, Red, Green, Blue) representation for the color& 0x00FFFFFF
"X6"
) Implementation
String code = (colorDialog1.Color.ToArgb() & 0x00FFFFFF).ToString("X6");
Edit: if you want to get Color
back from code
, try FromArgb
:
string code = "FFDDAA";
Color color = Color.FromArgb(Convert.ToInt32(code, 16));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With