ValidationConstraints Enumeration

 

Defines constants that inform ValidateChildren about how it should validate a container's child controls.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

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

[<FlagsAttribute>]
type ValidationConstraints

Member nameDescription
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.

By default, ValidateChildren will validate all enabled controls in a container, such as a form. Use this enumeration to restrict the types of controls whose Validating event is raised.

You can combine these enumerated values together with a bitwise OR operation. 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 Validating event on controls that are both immediate children of the container AND are enabled.

If you do not specify ImmediateChildren when you call ValidateChildren, the method will require that you validate all child controls in the control hierarchy.

The following code example will only cause the Validating event to be raised for immediate children of the form whose Enabled property is true.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top
Show: