Thursday, 1 September 2011

Validating a textbox control


In this application I’m validating a textbox by allowing only number to enter.
Create a windows application with a textbox control as shown in fig below.







Here what we do is add some code in keyPress event of the textbox control, which  will show a message when we enter a wrong data.Add the following code in the keyPress event of the textbox control









ValidateNumber(e.KeyChar) function is shown below


















Run the project and enter an alphabet,it will show a message box as shown below

No comments:

Post a Comment