ContainerControl.Validate 方法

定義

藉由依序讓 ValidatingValidated 事件發生,驗證失去焦點之控制項的值。Verifies the value of the control losing focus by causing the Validating and Validated events to occur, in that order.

多載

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

傳回

如果驗證成功,則為 true;否則為 falsetrue if validation is successful; otherwise, false. 如果從 ValidatingValidated 事件處理常式呼叫這個方法,則該方法一律會傳回 falseIf called from the Validating or Validated event handlers, this method will always return false.

備註

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.

另請參閱

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

參數

checkAutoValidate
Boolean

如果為 trueAutoValidate 屬性值就會用來判斷是否應該執行驗證,但如果為 false,就會無條件地執行驗證。If true, the value of the AutoValidate property is used to determine if validation should be performed; if false, validation is unconditionally performed.

傳回

如果驗證成功,則為 true;否則為 falsetrue if validation is successful; otherwise, false. 如果從 ValidatingValidated 事件處理常式呼叫這個方法,則該方法一律會傳回 falseIf called from the Validating or Validated event handlers, this method will always return false.

備註

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:

  • 如果 true``checkAutoValidate 參數,則不會驗證的子控制項一律會進行驗證。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.

另請參閱

適用於