BindingSource.SuspendBinding 方法

定義

暫止資料繫結以防止變更更新繫結的資料來源。Suspends data binding to prevent changes from updating the bound data source.

public:
 void SuspendBinding();
public void SuspendBinding ();
member this.SuspendBinding : unit -> unit
Public Sub SuspendBinding ()

備註

SuspendBindingResumeBinding 這兩種方法可讓您在簡單系結案例中暫時暫停和繼續資料系結。SuspendBinding and ResumeBinding are two methods that allow the temporary suspension and resumption of data binding in a simple-binding scenario. 如果使用者必須在進行驗證之前對資料欄位進行數個編輯,您通常會暫停資料系結。You would typically suspend data binding if the user must be allowed to make several edits to data fields before validation occurs. 例如,如果一個欄位必須根據第二個欄位變更,但驗證第一個欄位會導致第二個欄位發生錯誤,則為。For example, if one field must be changed in accordance with a second, but where validating the first field would cause the second field to be in error.

注意

使用 SuspendBinding 和可防止在呼叫之前將變更推送至資料來源 ResumeBinding ,但實際上不會防止發生任何事件。Using SuspendBinding and prevents changes from being pushed into the data source until ResumeBinding is called, but does not actually prevent any events from occurring. 使用複雜資料系結的控制項(例如 DataGridView 控制項)會根據事件之類的變更事件來更新其值 ListChanged ,因此呼叫 SuspendBinding 不會防止它們接收資料來源的變更。Controls that use complex data binding, such as the DataGridView control, update their values based on change events such as the ListChanged event, so calling SuspendBinding will not prevent them from receiving changes to the data source. 基於這個理由,這 SuspendBinding ResumeBinding 是專為搭配簡單繫結控制項(例如控制項)使用而設計的 TextBoxFor this reason, this SuspendBinding and ResumeBinding are designed for use with simple-bound controls, such as the TextBox control. 或者,如果您 ListChanged 將屬性設定為,就可以在複雜系結案例中使用這些方法 RaiseListChangedEvents falseAlternatively you can use these methods in a complex binding scenario if you suppress ListChanged events by setting the RaiseListChangedEvents property to false.

適用於

另請參閱