数量较少时文本框颜色发生变化 [英] textbox color change when quantity is less
本文介绍了数量较少时文本框颜色发生变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何机构都能帮助我更改文本框的背面颜色(用于显示
数量)在运行时小于5时.
在此先感谢
Can any body help me to change the back color of my text box(used to show
quantity) when the quantity became less than 5 on run time.
thanks in advance
推荐答案
试试这个:
Hi,
try this:
private void textBox2_TextChanged(object sender, EventArgs e)
{
int quantity = 0;
if (!Int32.TryParse(textBox2.Text, out quantity))
{
textBox2.BackColor = Color.Red;
return;
}
if (quantity < 5)
textBox2.BackColor = Color.Green;
else
textBox2.BackColor = Color.White;
}
这篇关于数量较少时文本框颜色发生变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文