文字框文字格式 [英] Textbox text format
本文介绍了文字框文字格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个文本框...我希望文本框仅接受数字0到9和小数点.因此,我能够使文本框仅接受具有以下内容的数字,但不接受小数点...我该怎么做...
Hi, I hav a textbox... I want textbox to accept only numbers 0 to 9 and decimal point. So I''m able to make the textbox to accept only numbers with the following but its not accepting the decimal point...How can i do it...
private void txtVanRef_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsDigit(e.KeyChar))
e.Handled = true;
}
推荐答案
if (!char.IsDigit(e.KeyChar) && e.KeyChar!=46)<br />
e.Handled = true;
这篇关于文字框文字格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文