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);
}
A TextBox which Accepts only Integer in C#
This blog defines a TextBox that accepts only integer in C#.


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