I have a Form with a TextBox. I would like to prevent the user from moving on to the next form without filling in the black TextBox. How can I do that?
if(textBox.Text.Length == 0)
MessageBox.Show("Have To Fill All The Fields!");
What more should I add?
Add handler to
Validatingevent and use error provider to set validation error to control:You can use same handler for several textbox controls (just use sender from event arguments to get particular textbox instance).