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

  1. get argb (alpha, red, green, blue) representation color
  2. filter out alpha channel: & 0x00ffffff
  3. format out value hexadecimal ("x6")

implementation

  string code = (colordialog1.color.toargb() & 0x00ffffff).tostring("x6"); 

Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -