加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 带代码颜色的ForeColor

发布时间:2020-12-15 04:10:31 所属栏目:百科 来源:网络整理
导读:我已经动态创建了HyperLink.我想通过添加颜色代码来改变颜色. HyperLink hpl = new HyperLink();hpl.Text = "SomeText";hpl.ForeColor = "#5BB1E6";//Cannot implicitly convert type 'string' to 'System.Drawing.Color 但我不能. 如何为ForeColor添加代码
我已经动态创建了HyperLink.我想通过添加颜色代码来改变颜色.
HyperLink hpl = new HyperLink();
hpl.Text = "SomeText";
hpl.ForeColor = "#5BB1E6";

//Cannot implicitly convert type 'string' to 'System.Drawing.Color

但我不能.

如何为ForeColor添加代码颜色?

可能吗?

解决方法

使用以下代码
HyperLink hpl = new HyperLink();
hpl.Text = "SomeText";
hpl.ForeColor = System.Drawing.ColorTranslator.FromHtml("#5BB1E6");

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读