Link to home
Start Free TrialLog in
Avatar of retep
retep

asked on

EditBox filter.

An easy way to make sure that the user only enters a key between '0..9', which means I only want the editbox to be able to contain numbers...

Regards
Peter :-)
Avatar of Lischke
Lischke

Hi Peter,

you have at least two options to try out. One is to use TMaskEdit with a proper mask to only accept numbers and the other is to intercept all keypresses to a normal TEdit and reject/ignore them if they aren't numbers.

The first solution is much easier and I'd suggest that you start working with TMaskEdit.

Ciao, Mike
ASKER CERTIFIED SOLUTION
Avatar of inthe
inthe

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 kretzschmar
just include also the backspace

If not (Key in ['0'..'9', #13, #8]) then
     Key := #0; //reject all other keys
Avatar of retep

ASKER

Just what I was looking for. Since my question was ment for TEdit, I have choosen to accept this particular answer.

But thanks to you all!

Peter :-)