如何防止datagridview VB.net中的负数和小数 [英] How to prevent negative and fractional numbers in datagridview VB.net

查看:107
本文介绍了如何防止datagridview VB.net中的负数和小数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用oledataadapter填充excel数据的datagridview。我正试图找到一种方法来阻止用户输入负数和小数。有没有一种简单的方法来防止这种情况?我非常感谢任何人给予的任何帮助或建议。

I'm using a datagridview populated with excel data using the oledataadapter. I'm trying to find a way to prevent the user from entering negative numbers as well as fractional numbers. Is there an easy way to prevent this? I greatly appreciate any help or suggestions anyone can give.

推荐答案

蒙面编辑栏 [ ^ ]



您可以使用该组件阻止用户输入您不想要的值。



唯一另一种方法是捕获EditingControlShowing事件,将编辑控件强制转换为文本框,然后捕获KeyPressEvent。然后使用典型的按键过滤代码,不允许用户输入 - 或。 (或任何非数字的)在文本框中。
Masked Edit Column[^]

You can use that component to keep your user from entering values that you don't want.

The only other way is to catch the EditingControlShowing event, cast the editing control to a text box, then capture the KeyPressEvent. Then use typical keypress filtering code to not allow the user to enter a "-" or "." (or anything non-numeric) in the text box.


这篇关于如何防止datagridview VB.net中的负数和小数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆