我想要标签中的forecolor [英] I want to forecolor in label

查看:58
本文介绍了我想要标签中的forecolor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有绿色(文字)



此绿色文字以绿色显示



同样我有红色(文字意味着)



这个红色文字用红色显示



为什么在asp.net中使用C#



我尝试了什么:

我有绿色(文字)



此绿色文字以绿色显示



同样我有红色(文字意味着)



这个红色文字用红色显示



for asp.net如何使用C#

in label i have Green (Text)

this Green text to be displayed in green color

similarly i have Red (text means)

this red text to be displayed in red color

for that how to do in asp.net using C#

What I have tried:

in label i have Green (Text)

this Green text to be displayed in green color

similarly i have Red (text means)

this red text to be displayed in red color

for that how to do in asp.net using C#

推荐答案

试试这个



try this

string text  = "Red color Green color";
 text = text.Replace("Red", "<span style='color:red'>Red</span>");
 text = text.Replace("Green", "<span style='color:green'>Green</span>");
 lbl.Text = text;





//输出

红色颜色绿色颜色



// output
Red color Green color


尝试:

Try:
myLabel.Text = "red!";
myLabel.ForeColor = Color.Red;




myLabel.Text = "green!";
myLabel.ForeColor = Color.Green;


这篇关于我想要标签中的forecolor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆