Textbox validation in a Windows Form

后端 未结 3 1444
不思量自难忘°
不思量自难忘° 2021-01-18 05:52

I want to put a validation that the user always enters a value in the textbox before submiting the form. But the check that I have put allows user to enter white spaces and

3条回答
  •  执笔经年
    2021-01-18 06:16

    in NET4.0 there is a nice function

     if(string.IsNullOrWhiteSpace(textBox1.Text))
    {
       //raise your validation exception
    }
    else {
      //go to submit
    }
    

提交回复
热议问题