Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 .
Posted

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.
 
Share this answer
 
Comments
You should try yourself. :)
aarif moh shaikh 7-Jul-15 0:29am    
yes loop in best way to do this
Use a loop here to check all the label box
C#
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900