This sets the textbox for only numbers
Numbers only textbox
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
char c = e.KeyChar;
//c == 8 is Backspace
//c == 32 is Space
//c == 13 is Carriage return (Enter)
// http://www.asciitable.com/ Tabel of ascii characters
if ((Char.IsDigit(c) || c == 8) || c == 32 || c == 13) return;
e.Handled = true; //
}
Mike Askew 131 Veteran Poster Featured Poster
Momerath 1,327 Nearly a Senior Poster Featured Poster
Michael27 29 Newbie Poster
Momerath 1,327 Nearly a Senior Poster Featured Poster
Michael27 29 Newbie Poster
ddanbe 2,724 Professional Procrastinator Featured Poster
Codefiva 0 Newbie Poster
RichardCh 0 Newbie Poster
Michael27 29 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.