We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

keypress event in currency cells

I cant seem to make a keypress event in a currency cell work properly. I''ve done it in text cells fine. What i''m trying to do is i have a currency cell where the user can only enter one digit with no decimal and it can only be between 0 and 3. so i was trying to not let them enter any number greater then 3. so in testing i have tried many things and the following lastly. If Asc(e.KeyChar) = 49 Then e.Handled = False Else e.Handled = True End If so in this case i was trying to just allow them to enter a 1. i cant even make that work. before i had an if with all the values or an if of >= to 48 and <= 51 with no luck. As i said i''ve made textbox cells only accept say an "X" and that works fine. Am I doing something wrong or going about this wrong???

1 Reply

AD Administrator Syncfusion Team May 7, 2004 06:43 PM

I do not know a good way to do this. The main problem is the embedded CurrecnyEdit control actually processes the key stroke in its ProcessKeyMessage, and then triggers an event that you catch and cancel, but by that time the key has already made it to the cell. I think the simplest thing to do is to use a standard TextBox for this cell. If all you is to allow 1 digit of 1, 2 or 3, you can handle CurrentCellValidateString and easily impose this requirement.

Loader.
Live Chat Icon For mobile
Up arrow icon