如果标签框的值大于0,则应为绿色 [英] if label boxes value grater than 0 it should be green

查看:74
本文介绍了如果标签框的值大于0,则应为绿色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有44个标签框,如果这些标签框的值大于0,那么它应该是绿色其他红色,是否可以创建一个功能来执行此操作。

I have 44 label boxes , if these label boxes value grater than 0 it should be green color other wise red, is it possible to create one function to do this .

推荐答案

遍历所有标签控件并检查label的值是否大于0。根据该值完成你的任务。
Loop through all the label controls and check if the value of label is greater than 0 or not. According to that value do your task.


在这里使用循环来检查所有标签框

Use a loop here to check all the label box
if(Convert.ToInt16(label2.Text)>=0)
{
    label2.BackColor=System.Drawing.Color.Green;
}
else
{
    label2.BackColor =System.Drawing.Color.Red;
}





这可以帮助您检查和更改颜色



this may help you to check and change color


这篇关于如果标签框的值大于0,则应为绿色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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