最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
颜色的转换
时间:2022-07-02 23:49:21 编辑:袖梨 来源:一聚教程网
上回我回复的看椰子林DotNet的天空-----ASP.NET组件编程step by step-------------------
# 回复:有点小BUG
//以下将颜色值转化成十六进制表示
string R,G,B;
R = (Convert.ToInt32(this._backgroundColor.R)).ToString("X");
G = (Convert.ToInt32(this._backgroundColor.G)).ToString("X");
B = (Convert.ToInt32(this._backgroundColor.B)).ToString("X");
if(R.Length==1)R = "0" + R;
if(G.Length==1)G = "0" + G;
if(B.Length==1)B = "0" + B;
-----------------------------------
其实以下代码可以换成一行代码就搞定--------------------
//以下将颜色值转化成十六进制表示
string R,G,B;
R = (Convert.ToInt32(this._backgroundColor.R)).ToString("X");
G = (Convert.ToInt32(this._backgroundColor.G)).ToString("X");
B = (Convert.ToInt32(this._backgroundColor.B)).ToString("X");
if(R.Length==1)
R = "0" + R;
if(G.Length==1)
G = "0" + G;
if(B.Length==1)
B = "0" + B;
Table t=(Table)Controls[i];
t.Attributes.Add("id",t.ClientID);
this.textBox.Attributes["onfocus"]="ltmouseover("+t.ClientID+",'" + "#" + R + G + B + "')";
--------改成-------------------------
this.textBox.Attributes.Add("onmouseover","ltmouseover(this,'" + ColorTranslator.ToHtml(this._mouseoverColor) + "')");
简单吧!无意中发现的!因为我想想MS不可能把一个颜色转换要自己写得这么麻烦。
# 回复:有点小BUG
//以下将颜色值转化成十六进制表示
string R,G,B;
R = (Convert.ToInt32(this._backgroundColor.R)).ToString("X");
G = (Convert.ToInt32(this._backgroundColor.G)).ToString("X");
B = (Convert.ToInt32(this._backgroundColor.B)).ToString("X");
if(R.Length==1)R = "0" + R;
if(G.Length==1)G = "0" + G;
if(B.Length==1)B = "0" + B;
-----------------------------------
其实以下代码可以换成一行代码就搞定--------------------
//以下将颜色值转化成十六进制表示
string R,G,B;
R = (Convert.ToInt32(this._backgroundColor.R)).ToString("X");
G = (Convert.ToInt32(this._backgroundColor.G)).ToString("X");
B = (Convert.ToInt32(this._backgroundColor.B)).ToString("X");
if(R.Length==1)
R = "0" + R;
if(G.Length==1)
G = "0" + G;
if(B.Length==1)
B = "0" + B;
Table t=(Table)Controls[i];
t.Attributes.Add("id",t.ClientID);
this.textBox.Attributes["onfocus"]="ltmouseover("+t.ClientID+",'" + "#" + R + G + B + "')";
--------改成-------------------------
this.textBox.Attributes.Add("onmouseover","ltmouseover(this,'" + ColorTranslator.ToHtml(this._mouseoverColor) + "')");
简单吧!无意中发现的!因为我想想MS不可能把一个颜色转换要自己写得这么麻烦。
相关文章
- 决胜巅峰古德最强怎么出装最有效 06-07
- 仙剑世界海魂剑怎样 06-07
- 数学货币用的什么软件 数字货币比特币app 排行前十的买币平台 06-07
- 碧蓝航线浮樱影华复刻白雪驱逐舰历史原型攻略 06-07
- 深空之眼沐风恩利尔技能强度怎么样 06-07
- 国内炒币 前十名数字货币交易软件排名盘点 06-07