ContainerControl.Validate Method

Definition

通过以该顺序引发 ValidatingValidated 事件,验证失去焦点的控件的值。Verifies the value of the control losing focus by causing the Validating and Validated events to occur, in that order.

Overloads

Validate()

通过以该顺序引发 ValidatingValidated 事件,验证失去焦点的控件的值。Verifies the value of the control losing focus by causing the Validating and Validated events to occur, in that order.

Validate(Boolean)

验证失去焦点的控件的值;有条件地取决于是否打开了自动验证。Verifies the value of the control that is losing focus; conditionally dependent on whether automatic validation is turned on.

Validate()

通过以该顺序引发 ValidatingValidated 事件,验证失去焦点的控件的值。Verifies the value of the control losing focus by causing the Validating and Validated events to occur, in that order.

public:
 bool Validate();
public bool Validate ();
member this.Validate : unit -> bool
Public Function Validate () As Boolean

Returns

Boolean

如果验证成功,则为 true;否则为 falsetrue if validation is successful; otherwise, false. 如果是从 ValidatingValidated 事件处理程序调用的,则该方法将始终返回 falseIf called from the Validating or Validated event handlers, this method will always return false.

Remarks

Validate 方法将验证未验证的最后一个子控件及其上级,但不包括当前容器控件。The Validate method validates the last child control that is not validated and its ancestors up through, but not including, the current container control. 此重载版本始终执行验证,与控件的父级的 AutoValidate 属性的值无关。This overloaded version always performs validation, regardless of the value of the AutoValidate property of the control's parent. 因此,使用它来无条件地强制进行验证。Therefore use it to unconditionally force validation.

See also

Validate(Boolean)

验证失去焦点的控件的值;有条件地取决于是否打开了自动验证。Verifies the value of the control that is losing focus; conditionally dependent on whether automatic validation is turned on.

public:
 bool Validate(bool checkAutoValidate);
public bool Validate (bool checkAutoValidate);
member this.Validate : bool -> bool
Public Function Validate (checkAutoValidate As Boolean) As Boolean

Parameters

checkAutoValidate
Boolean

如果为 true,则使用 AutoValidate 属性的值来确定是否应执行验证;如果为 false,则无条件地执行验证。If true, the value of the AutoValidate property is used to determine if validation should be performed; if false, validation is unconditionally performed.

Returns

Boolean

如果验证成功,则为 true;否则为 falsetrue if validation is successful; otherwise, false. 如果是从 ValidatingValidated 事件处理程序调用的,则该方法将始终返回 falseIf called from the Validating or Validated event handlers, this method will always return false.

Remarks

Validate 方法将验证未验证的最后一个子控件及其上级,但不包括当前容器控件。The Validate method validates the last child control that is not validated and its ancestors up through, but not including, the current container control. 此重载版本根据以下条件执行验证:This overloaded version performs validation based on the following conditions:

  • 如果 checkAutoValidate 参数 true,则对于未验证的子控件,将始终发生验证。If the checkAutoValidate parameter is true, validation always occurs for child controls that are not validated.

  • 如果 false``checkAutoValidate 参数,则仅当启用控件的父级的 AutoValidate 属性时才会进行验证。If the checkAutoValidate parameter is false, validation occurs only if the AutoValidate property of the control's parent is enabled.

See also

Applies to