【发布时间】:2015-06-02 21:53:01
【问题描述】:
我只是想知道是否可以简化这些代码?我有多个文本框具有相同的 textchange 事件
private void txtOvertimeHours_TextChanged(object sender, EventArgs e)
{
if (txtOvertimeHours.Text.Length <= 0 ||
txtOvertimeHours.Text == null ||
txtOvertimeHours.Text == "0.00" ||
txtOvertimeHours.Text == "0" ||
txtOvertimeHours.Text == "0.0")
{
txtOvertimeHours.Text = "0.00";
}
}
private void txtAllowance_TextChanged(object sender, EventArgs e)
{
if (txtAllowance.Text.Length <= 0 ||
txtAllowance.Text == null ||
txtAllowance.Text == "0.00" ||
txtAllowance.Text == "0" ||
txtAllowance.Text == "0.0")
{
txtAllowance.Text = "0.00";
}
}
//等等
【问题讨论】:
-
Winforms、webforms、wpf、什么?
-
winform 先生@JohnSaunders
标签: c# winforms visual-studio-2010 visual-studio