c# - How to get the hex color code from a color dialog in visual studio? -
this question has answer here:
i have color dialog in visual studio, using c# code display color dialog , set color panel:
private void colorbutton_click(object sender, eventargs e) { if (colordialog1.showdialog() == dialogresult.ok) { colorpanel.backcolor = colordialog1.color; } }
how set label hexadecimal color code of color picker?
you can try this
- get
argb
(alpha, red, green, blue) representation color - filter out alpha channel:
& 0x00ffffff
- format out value hexadecimal (
"x6"
)
implementation
string code = (colordialog1.color.toargb() & 0x00ffffff).tostring("x6");
Comments
Post a Comment