DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Only Allow Numbers In Textbox
// This can be expanded to limit the key pressed to whatever you want
//In this scenario it only allows digits
void textBox_KeyPress(object sender, KeyPressEventArgs e)
{
e.Handled = !(Char.IsDigit(e.KeyChar) || e.KeyChar == '\b');
}





