Allow only integers in TextBoxes

后端 未结 6 1362
情书的邮戳
情书的邮戳 2021-01-22 12:45

I\'m having a problem with checking textboxes and making sure there\'s only integers in them.

So far I\'m able to confirm that there\'s text in the textboxes, but checki

6条回答
  •  时光说笑
    2021-01-22 13:26

    Using your current pattern, something like this:

    int tester;
    if (!Int32.TryParse(textBox1.Text, out tester))
    {
        errorProvider1.SetError(textBox1, "must be integer");
        return;
    }
    

提交回复
热议问题