Iat*_*ist 1 .net c# events design-patterns
我正在使用C#在win表单中编写桌面应用程序.我使用以下代码将文本框转换为数字文本框:
private void txtPrice_KeyPress(object sender, KeyPressEventArgs e)
{
//if (!char.IsControl(e.KeyChar)
// && !char.IsDigit(e.KeyChar)
// && e.KeyChar != '.')
// {
// e.Handled = true;
// }
if(!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar))
{
e.Handled = true;
}
}
Run Code Online (Sandbox Code Playgroud)
是什么蚂蚁设计模式或技术只编写一次上面的代码,并且不写,每次为表单中的每个文本框?
| 归档时间: |
|
| 查看次数: |
175 次 |
| 最近记录: |