Drag and drop a TextBox. Now, go to in property of the textbox and double click on the "KeyPress event".
priavate void textbox_keypress(obj sender_event e)
{
if(e.keychar >= '0' && e.keychar <= '9')
{
e.handled = false;
}
else
{
e.handle = true;
}
}
Before doing this code, it is necessary for the keypress event to write this code:
public form()
{
initializeComponent();
textbox.text.keypress + = new keypressEventHandler(text.box_keypress);
}
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.

Munesh SharmaPosted Mar 19, 2014, 7:13 AM
yes vasanthasilvary... you can use it in window application.
vasanthasilvaryPosted Mar 19, 2014, 7:06 AM
I think this is for wpf right?