本文介绍了文本框在C#中只接受数字和.57值等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 如果想在文本框中获得.54起始值 我尝试过: public static void NumericValidationOnlyOneDot( object sender,KeyPressEventArgs e) { e.Handled =!char.IsDigit( e.KeyChar)&& !char.IsControl(e.KeyChar)&& e.KeyChar!= ' 。'&& e.KeyChar!= ' - '; if ((e.KeyChar == ' 。)&&((sender as TextBox).Text.IndexOf(' 。')> = 1 )) { e.Handled = false ; } } i试过这个但不适用于.54起始值等解决方案 if want to get .54 starting values in textboxWhat I have tried:public static void NumericValidationOnlyOneDot(object sender, KeyPressEventArgs e) {e.Handled = !char.IsDigit(e.KeyChar) && !char.IsControl(e.KeyChar) && e.KeyChar != '.' && e.KeyChar!='-'; if ((e.KeyChar == '.') && ((sender as TextBox).Text.IndexOf('.') >= 1)) { e.Handled = false; }}i have tried this but not working for .54 starting values etc 解决方案 这篇关于文本框在C#中只接受数字和.57值等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-30 00:29