Link to home
Start Free TrialLog in
Avatar of Jose Bredariol
Jose BredariolFlag for Brazil

asked on

How to accept only numbers in VS2008 Datagridview cell for windows application ?

I'm using Visual Studio 2008 DatagridView.
SOLUTION
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jose Bredariol

ASKER

I tried this code, but I think this is for C#. I need something similar to VS2008 (VBA). Thanks
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Both answers works for me. Thanks
Avatar of gadavis2
gadavis2

You could just use the RegularExpressionValidator with the proper regex string to allow numbers only.  Try placing the following code within the <EditItemTemplate></EditItemTemplate> for the field you want to control.

Check out http://regexlib.com/Search.aspx?k=numbers%20only for more regular expressions to use.  This is where I got the one for allows numbers only.  Good luck.
<asp:RegularExpressionValidator id="reNumbersOnly" runat="server" ControlToValidate="txtFieldToControl" ValidationExpression="^[+]?\d*$" Text="Numbers Only Please." />

Open in new window

I'll try this too. Thanks