更改标签的颜色 [英] Change the color of label
本文介绍了更改标签的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有3个选项可以更改标签的颜色
1 - 红色
2 - 绿色
3 - yallow
我创建了100个标签。
我有桌子包含标签的名称和选项的价值
名称的选项
A1 1
A2 2
A3 1
A4 3
A8 1
B1 1
B3 2
如何更改标签的颜色?或者还有其他方式
I have 3 option to change the color of label
1 - Red
2 - Green
3 - yallow
I created 100 labels.
I have table contains the name of the lable and the value of option
NAME OF LABLE OPTION
A1 1
A2 2
A3 1
A4 3
A8 1
B1 1
B3 2
How can I change the colors of labels? or there is other way
推荐答案
尝试:
Try:
foreach (Control c in Controls)
{
Label l = c as Label;
if (l != null)
{
l.ForeColor = Color.Red;
l.BackColor = Color.Green;
}
}
您可能需要递归地对主窗体上的容器控件执行相同的操作。
You may need to recursively do the same thing for container controls on the main form.
这篇关于更改标签的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文