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

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -