Back to Devexpress

RichEditControl.TrackedMovesConflict Event

windowsforms-devexpress-dot-xtrarichedit-dot-richeditcontrol-444d70fb.md

latest5.3 KB
Original Source

RichEditControl.TrackedMovesConflict Event

Occurs when moved text has been changed since it was moved.

Namespace : DevExpress.XtraRichEdit

Assembly : DevExpress.XtraRichEdit.v25.2.dll

NuGet Package : DevExpress.Win.RichEdit

Declaration

csharp
public event TrackedMovesConflictEventHandler TrackedMovesConflict
vb
Public Event TrackedMovesConflict As TrackedMovesConflictEventHandler

Event Data

The TrackedMovesConflict event's data class is TrackedMovesConflictEventArgs. The following properties provide information specific to this event:

PropertyDescription
NewLocationRangeProvides access to the range of the moved text’s new location.
OriginalLocationRangeRetrieves the range of the moved text’s original location.
ResolveModeGets or sets what version of moved text to keep.
RevisionProvides access to the revision whose rejection fired the event.

Remarks

Handle this event to resolve the conflict when the moved text has been changed (i.e., new text has been inserted) since it was moved, and the move was rejected.

The event does not occur if new revision in the moved text was rejected.

You can obtain the original and new location range (OriginalLocationRange and NewLocationRange properties), and the revision whose rejection fired this event (the Revision property). Use the ResolveMode property to specify the version you want to keep.

The code sample below shows how to handle the TrackedMovesConflict event to keep original text:

csharp
private void WordProcessor_TrackedMovesConflict(object sender, TrackedMovesConflictEventArgs e)
{
  //Compare the length of the original and new location ranges
  //Keep text from the location whose range is the smallest
  e.ResolveMode = (e.OriginalLocationRange.Length <= e.NewLocationRange.Length) ? TrackedMovesConflictResolveMode.KeepOriginalLocationText : TrackedMovesConflictResolveMode.KeepNewLocationText;
}
vb
Private Sub WordProcessor_TrackedMovesConflict(ByVal sender As Object, ByVal e As TrackedMovesConflictEventArgs)
    'Compare the length of the original and new location ranges
    'Keep text from the location whose range is the smallest
    e.ResolveMode = If((e.OriginalLocationRange.Length <= e.NewLocationRange.Length), TrackedMovesConflictResolveMode.KeepOriginalLocationText, TrackedMovesConflictResolveMode.KeepNewLocationText)
End Sub

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the TrackedMovesConflict event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-rich-edit-manage-tracked-changes/CS/XtraRichEdit_TrackChanges/Form1.cs#L23

csharp
richEditControl1.LoadDocument("DocumentWithRevisions.docx");
richEditControl1.TrackedMovesConflict += DocumentProcessor_TrackedMovesConflict;
richEditControl1.Document.SaveDocument("DocumentWithRevisions.docx", DocumentFormat.OpenXml);

winforms-rich-edit-manage-tracked-changes/VB/XtraRichEdit_TrackChanges/Form1.vb#L18

vb
richEditControl1.LoadDocument("DocumentWithRevisions.docx")
AddHandler richEditControl1.TrackedMovesConflict, AddressOf DocumentProcessor_TrackedMovesConflict
richEditControl1.Document.SaveDocument("DocumentWithRevisions.docx", DocumentFormat.OpenXml)

See Also

RichEditControl Class

RichEditControl Members

DevExpress.XtraRichEdit Namespace