ערוך

שתף באמצעות


TextChangedEventArgs.Changes Property

Definition

Gets a collection of objects that contains information about the changes that occurred.

public:
 property System::Collections::Generic::ICollection<System::Windows::Controls::TextChange ^> ^ Changes { System::Collections::Generic::ICollection<System::Windows::Controls::TextChange ^> ^ get(); };
public System.Collections.Generic.ICollection<System.Windows.Controls.TextChange> Changes { get; }
member this.Changes : System.Collections.Generic.ICollection<System.Windows.Controls.TextChange>
Public ReadOnly Property Changes As ICollection(Of TextChange)

Property Value

A collection of objects that contains information about the changes that occurred.

Remarks

There is one TextChange object for each consecutive change to the control. More than one consecutive change can occur during one occurrence of the TextChanged event when the change entails changing the structure of the underlying document.

For example, suppose that a RichTextBox contains the string "This is some text." The structure of the RichTextBox.Document is <Paragraph><Run>This is some text.</Run></Paragraph>. If the user bolds the words "is some", the structure of the underlying FlowDocument changes to <Paragraph><Run>This </Run><Run FontWeight="Bold">is some</Run><Run> text.</Run></Paragraph>. There are actually four changes that took place as a result of the user's action:

  1. The <Run> symbol is removed and re-added before the word This.

  2. The symbols </Run><Run> are added after the word This.

  3. The symbols </Run><Run> are added after the word some.

  4. The </Run> symbol is removed and re-added after the word Text.

In general, the following will always be true:

  • The changes that occur result in the document being in a valid state.

  • The collection is ordered consecutively, related to where the change occurred in the control. For example, a TextChange object that represents a change at position 2 is before a TextChange object that represents a change at position 10.

  • Two TextChange objects do not represent an overlapping area. The value of Offset plus the value of AddedLength of one TextChange object is always less than or equal to the value of Offset of the next TextChange object in the collection. Likewise, the value of Offset plus the value of RemovedLength of one TextChange object is always less than or equal to the value of Offset of the next TextChange object in the collection.

  • The collection reflects whatever changes occurred, even if there seems to be no net change. In the preceding example, neither the first or fourth change results in a net change, because each simply removed and re-added the <Run> and </Run> symbols, respectively. But the symbols were actually removed and added, so they are included in the collection.

If the TextChanged event occurs as a result of a property change, Changes is an empty collection. In the preceding example, if the user bolds the entire string, the FontWeight property of the Run is set to Bold, but nothing is added or removed from the document, so Changes is empty.

Changes is introduced in the .NET Framework version 3.5. For more information, see Versions and Dependencies.

Applies to