Is this just a case of limiting the number of characters input in the textbox ? Or are you specifically trying to prevent more than four numeric characters being entered ?
If the first is true can you not just set the 'MaxLength' (integer) property against the desired TextBox component ?
I'm hoping that I've not simply missed the point on this one.
Steve
Can you not just check the text as entered into the control as you exit it (validating it as such) ?
Alternatively could you not make use of the 'KeyPress' event and the 'KeyChar' to obtain the keyboard character that was pressed.
Steve
I tried out the code that SameerKhan pointed out (written by Jibin Pan) and it works quite well. It is easily modified & customized for specific needs and error handling.
---
dino
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.