0

I don't know if i'm going crazy or what but I've looked for hours and I can't find a way to limit user number input for a WinForm application for a minimum of .001 to a max of 1000. Could anyone show me the code for this?

private void Height_KeyPress(object sender, KeyPressEventArgs e)
{
    if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) &&
            (e.KeyChar != '.'))
    {
        e.Handled = true;
        MessageBox.Show("Please enter only numeric values.");
    }
    // only allow one decimal point
    if ((e.KeyChar == '.') && ((sender as TextBox).Text.IndexOf('.') > -1))
    {
        e.Handled = true;
    }
}
Imran Sh
  • 1,623
  • 4
  • 27
  • 50

0 Answers0