本文介绍了如何限制用户不要在windows窗体的datagridview中输入小数点后超过2位数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



i有一个datagridview,我们在单元格中输入价格..

用户的价格在小数点后不得超过2位数。

例如他的价格都是9.99 / 99.99 / 999.99 / 9999.99 / 99999.99 / 999999.99 .....

但不像9.999 / 9.9999 / 9.99999



i写了一个代码,我们在其中输入两位数以上,在单元格离开之后重复出现并显示两位数字,如8.89999,它将在单元格离开后显示8.90,因为它将重复出现。



但我不想再经常发生。它应该限制输入超过两位数。

喜欢




i have a datagridview in which we enter prices in cells..
user's prices doesnt not have more than 2 digits after decimal point..
for example his prices all are like 9.99/99.99/999.99/9999.99/99999.99/999999.99 .....
but not like 9.999/9.9999/9.99999

i written a code in which we enter more than two digits, after cell leave it was recurring and displaying two digits only like 8.89999 it will display 8.90 after cell leave as it will recur.

but i dont want recurring. it should restrict entering more than two digits.
like

if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && e.KeyChar != '.')
            {
                e.Handled = true;
            }


这个代码中的
它将限制输入字母...

这样我想要一个应该只限制两个的代码小数点后的数字.....



先谢谢


in this code it will restrict entering alphabetic letters..
like this i want a code which should restrict only two digits after decimal point.....

Thanks in Advance

推荐答案


这篇关于如何限制用户不要在windows窗体的datagridview中输入小数点后超过2位数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 12:23