if (!(e.KeyChar >= '0' && e.KeyChar <= '9' || e.KeyChar == '.')) e.Handled = true; if (e.KeyChar == '\b') e.Handled = false;