Only Double Must be Accepted in the textBox.
How can I accept only double numbers in a textbox while typing in it? I dont use with a button this textbox. I am taking the input while typing. A you know user can input a number like 5E11. When a user wrote "E" his input become "5E" before he finished typing the number and "5E" is not a double. What code do you suggest for me?
Santhosh Kumar JayaramanPosted Dec 27, 2012, 3:06 AM
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if ((e.KeyChar < 48 || e.KeyChar > 57) && e.KeyChar != 46
&& e.KeyChar != 8)
e.Handled = true;
}
48-57 will be numbers
46- decimal point
8-backspace
This will allow users to type only numbers, decimal and backspace