Step by step to Control Validation:
Add a Form
Go to Form Property window.
Disable Auto Validate .
Add a Text Box in the Form.
Add a Button in the Form.
Verify Causes Validation is true.
Add a Form
Go to Form Property window.
Disable Auto Validate .
Add a Text Box in the Form.
Add a Button in the Form.
Verify Causes Validation is true.
if (textBox1.Text.Length == 0)
{
e.Cancel = true;
}
else
{
e.Cancel = false;
}
if (this.ValidateChildren())
{
MessageBox.Show("Validation succeeded!");
}
else
{
MessageBox.Show("Validation failed.");
}
No comments:
Post a Comment