如何从后面的代码中设置标签文本的颜色 [英] how to set color some text of label from code behind

查看:110
本文介绍了如何从后面的代码中设置标签文本的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

单击按钮时,我正在如下设置Label1的值.

Label1.Text =我的名字是wasif";

现在我要以橙色显示wasif.

如何在后面的代码中实现它.

感谢

解决方案

,您可以使用字符串函数string.split分隔标签字符串,其中需要根据空格分隔字符.这将返回字符串数组.您将获得数组.在数组的第三个索引上,设置颜色..您可以使用两个不同的标签.第一个显示前三个字符的标签,另一个显示名称的标签.


看看提供的解决方案..
如何在标签中使用两种颜色c# [ ^ ]

http://social. msdn.microsoft.com/Forums/vstudio/zh-CN/c571ec59-df07-4b28-a809-203c27f6ac90/label-with-multiple-color [ label1.Text = " ;


Hi All,

On click of a button I am setting value of a Label1 as below.

Label1.Text="My name is wasif";

Now I want to display wasif in orange color.

How to implement it in code behind.

thanks

you can seperate your label string using string function string.split where characters need to be seperated based on space. This will return array of strings. You will get array. the on 3rd index of array, set your color .. you can use two different labels. the first label to show first three characters and another label to show name..


Have a look at the solutions provided at..
how to use two colors in label for text in c#[^]

http://social.msdn.microsoft.com/Forums/vstudio/en-US/c571ec59-df07-4b28-a809-203c27f6ac90/label-with-multiple-color[^]


label1.Text = "testing <font color='orange'>orange</font>";


这篇关于如何从后面的代码中设置标签文本的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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