Now TextBox in Windows application of C# have something called as events
all u have to do is use the KeyPress event of the textbox and paste in the following code...
The below code will work with integers a better option would be to use regular expression
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (char.IsNumber(e.KeyChar) == false)
{
e.Handled = true;
}
if (e.KeyChar == (char)Keys.Back)
{
e.Handled = false;
}
}
and ur done...
Do rate my answer once u find it useful
Thanks & Regards
Radix :rose: