I am having problems with controls on a panel not firing. The controls that
are directly on the form will validate, but the controls on the panel will
not validate.
I have the AutoValidate property for the form set to EnableAllowFocusChange
and then I call the ValidateChildren method when the save button is clicked.
If I cannot get the form to validate the controls, can I loop through each
control and call the validate event?
Thanks
private void toolStripReviewActionItemsSaveItem_Click(object sender,
EventArgs e)
{
// Validate all of the children controls
// If any controls fail validation then show message box and return
if (!this.ValidateChildren(ValidationConstraints.Enabled))
{
// At least one of the controls failed validation
MessageBox.Show(
"Please correct the data and attempt the save again.",
this.Text + " - Invalid Data",
MessageBoxButtons.OK,
MessageBoxIcon.Error,
MessageBoxDefaultButton.Button1);
// Return from the form and correct the bad data
return;
}
// Validation was successful so save the dataset to the database
doActionItemsSaveRecord();
// Disable the controls that are used to add or edit records
disableActionItemsAddEdit();
}