colors - c# colorpicker and loading -


i have got colorpicker save user selection text file, , color gets loaded @ program startup. problem using .toknowncolor(); fine, there colours in colorpicker swatch doesn't - fine black/white/yellow/red/blue/etc - basic colours, when starts going different shades of colour, doesn't it. assuming because not known color. have tried other 2 options (toargb() + tostring()) can't them work. here have;

//in linklabel private void textcol_linkclicked(object sender, linklabellinkclickedeventargs e)         {             colordialog textcolour = new colordialog();             textcolour.allowfullopen = false;             textcolour.showhelp = true;             if (textcolour.showdialog() == dialogresult.ok)             {                 #region labels                 label1.forecolor = textcolour.color;               if (customise == true)                 {                     file.writealltext("c:/bmw/colours/textcol.txt", textcolour.color.toknowncolor() + "");                 }             }         }  //at top public form1()     {         initializecomponent();         invoicesavepath.text = file.readalltext("c:/bmw/invoice save path.txt");         string[] textcol = file.readalllines("c:/bmw/colours/textcol.txt");         label1.forecolor = color.fromname(textcol[0]);     } 

so user changes colour linklabel, writes txt file, loads again on next startup. works basic colors, not others - how can make work swatch colors - not wanting use custom color option...standard swatch :)

thanks

you should use argb functions.

to write:

file.writealltext("c:/bmw/colours/textcol.txt", textcolour.color.toargb().tostring()); 

to read / parse:

label1.forecolor = color.fromargb(int.parse(textcol[0])); 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -