Note: This method is new in the .NET Framework version 2.0.
Causes all of the child controls within a control that support validation to validate their data.
Return Value
true if all of the children validated successfully; otherwise, false.
ValidateChildren will descend a control's hierarchy and examine each control to see if it supports validation. If the control can be selected by the user and its CausesValidation property is true, ValidateChildren will cause the Validating event to occur. If any of the controls cancel the Validating event, this method will return false; otherwise, it will return true.
If a control is bound to a data source, and the Validating event occurs, it will cause the control to push its current data back to the data source.
Calling ValidateChildren is equivalent to calling ValidateChildren with a ValidationConstraints of None.
ValidationConstraints Members
Member name | Description | |
---|---|---|
Enabled | Validates child controls whose Enabled property is set to true. | |
ImmediateChildren | Validates child controls that are directly hosted within the container. Does not validate any of the children of these children. For example, if you have a Form that contains a custom UserControl, and the UserControl contains a Button, using ImmediateChildren will cause the Validating event of the UserControl to occur, but not the Validating event of the Button. | |
None | Validates all child controls, and all children of these child controls, regardless of their property settings. | |
Selectable | Validates child controls that can be selected. | |
TabStop | Validates child controls that have a TabStop value set, which means that the user can navigate to the control using the TAB key. | |
Visible | Validates child controls whose Visible property is set to true. |