共用方式為


TextBoxBase.EndChange 方法

定義

結束變更區塊。

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

範例

下列範例示範如何使用 BeginChangeEndChange 方法來建立變更區塊。

TextBox myTextBox = new TextBox();

// Begin the change block. Once BeginChange() is called
// no text content or selection change events will be raised 
// until EndChange is called. Also, all edits made within
// a BeginChange/EndChange block are wraped in a single undo block.
myTextBox.BeginChange();

// Put some initial text in the TextBox.
myTextBox.Text = "Initial text in TextBox";

// Make other changes if desired...

// Whenever BeginChange() is called EndChange() must also be
// called to end the change block.
myTextBox.EndChange();
Dim myTextBox As New TextBox()

' Begin the change block. Once BeginChange() is called
' no text content or selection change events will be raised 
' until EndChange is called. Also, all edits made within
' a BeginChange/EndChange block are wraped in a single undo block.
myTextBox.BeginChange()

' Put some initial text in the TextBox.
myTextBox.Text = "Initial text in TextBox"

' Make other changes if desired...

' Whenever BeginChange() is called EndChange() must also be
' called to end the change block.
myTextBox.EndChange()

備註

注意

當您呼叫 BeginChange 時,也必須呼叫 EndChange 以完成變更區塊,否則會擲回例外狀況。

變更區塊會以邏輯方式將多個變更分組到單一復原單位,並防止在變更區塊之後引發文字內容或選取範圍變更事件。 如此一來,您就可以對文字元素進行多個編輯,而不會讓另一個進程同時變更文字元素的危險。 呼叫 方法會建立 DeclareChangeBlock 變更區塊。 BeginChange呼叫 方法會導致指定變更區塊中包含所有後續的變更,直到對 方法的對應呼叫 EndChange 為止。

適用於

另請參閱