System.Drawing.Color的几种使用方法

System.Drawing.Color   cl   =   Color.Red;

System.Drawing.Color   cl   =   Color.FromArgb(255,0,0);

myDataGrid.BorderColor=Color.FromName("#DEBA84");

颜色和字符串之间的关系:

1、将颜色转换成字符串

string c1 = System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.Red);

// c1 = "#ff0000";或c1 = "Red";

2、用的时候再取出转换成颜色

System.Drawing.Color c2 = System.Drawing.ColorTranslator.FromHtml("#ff0000");

原文地址:https://www.cnblogs.com/net2012/p/3364602.html