System.Windows.Forms.ContainerControl.ValidateChildren Method

Causes all of the child controls within a control that support validation to validate their data.

Syntax

[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[System.ComponentModel.Browsable(false)]
public virtual bool ValidateChildren (ValidationConstraints validationConstraints)

Parameters

validationConstraints
Places restrictions on which controls have their Control.Validating event raised.

Returns

true if all of the children validated successfully; otherwise, false. If called from the Control.Validating or Control.Validated event handlers, this method will always return false.

Remarks

ContainerControl.ValidateChildren(ValidationConstraints) will examine all the children of the current control, causing the Control.Validating event to occur on a control if it meets the criteria spelled out by System.Windows.Forms.ValidationConstraints.

You may use several System.Windows.Forms.ValidationConstraints parameters at once by combining them with a bitwise OR operator. Combining parameters with a bitwise OR operator will result in a logical AND operation. For example, calling ValidateChildren(ValidationConstraints.ImmediateChildren | ValidationConstraints.Enabled) will only raise the Control.Validating event on controls that are both immediate children of the container AND are enabled.

Regardless of which parameters you specify for this method, a control must have its Control.CausesValidation property set to true in order for its Control.Validating event to occur. You should also set the ContainerControl.AutoValidate property of the control or of the control's container to false if you want validation to happen only when you call ContainerControl.ValidateChildren(ValidationConstraints), and not when the user shifts focus from the control.

If a control is bound to a data source, and the Control.Validating event occurs, it will cause the control to push its current data back to the data source.

You cannot achieve the opposite effect of a System.Windows.Forms.ValidationConstraints parameter by applying a bitwise negation operator. For example, if you supply the negative value of the ValidationConstraints.Visible field to ContainerControl.ValidateChildren(ValidationConstraints), it will not validate all children that are not visible on the container. Supplying any negative parameter to ContainerControl.ValidateChildren(ValidationConstraints) will have no effect on the container or its children.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 2.0.0.0