How to make a Textbox only take numbers?
-
I made a C# application and i want the Textbox control to just take numbers and no characters. In VC++ this can be easily done by setting a property. Any idea how to do this in C#? Thanks
Handle the keypress event and check input
-
I made a C# application and i want the Textbox control to just take numbers and no characters. In VC++ this can be easily done by setting a property. Any idea how to do this in C#? Thanks
this is easy thing. you can set as : this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox1_KeyPress); private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if ( !( char.IsDigit( e.KeyChar ) ) ) { e.Handled = true; } }
roger wong msn:wenmianbj@hotmail.com
-
I made a C# application and i want the Textbox control to just take numbers and no characters. In VC++ this can be easily done by setting a property. Any idea how to do this in C#? Thanks
-
this is easy thing. you can set as : this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox1_KeyPress); private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if ( !( char.IsDigit( e.KeyChar ) ) ) { e.Handled = true; } }
roger wong msn:wenmianbj@hotmail.com