Tracked changes is also known as red-lining - a way to track changes done by users to a document. Displaying these changes in various colors can be distracting. This sample code shows how to turn the rendering of the markup on and off.
The following code uses a variable _isMarkupVisible
that defines whether the markup should be rendered or not. In the Changed ╰ TX Text Control .NET for Windows Forms
╰ TXTextControl Namespace
╰ TextControl Class
╰ Changed Event
Indicates that the contents of a document have been changed. event, the ToggleMarkup
method is called.
private bool _isMarkupVisible = true; | |
private void btnToggleMarkup_Click(object sender, EventArgs e) { | |
_isMarkupVisible = !_isMarkupVisible; | |
ToggleMarkup(); | |
} | |
private void textControl1_Changed(object sender, EventArgs e) { | |
ToggleMarkup(); | |
} | |
private void ToggleMarkup() { | |
foreach (TXTextControl.TrackedChange change in textControl1.TrackedChanges) { | |
if (change.ChangeKind == TXTextControl.ChangeKind.DeletedText) | |
continue; | |
change.HighlightMode = _isMarkupVisible == true ? | |
TXTextControl.HighlightMode.Always : | |
TXTextControl.HighlightMode.Never; | |
} | |
} |
This method loops through all Tracked ╰ TX Text Control .NET for Windows Forms
╰ TXTextControl Namespace
╰ TrackedChange Class
A TrackedChange object represents a change made to the document after anyone has revised the document. objects to set the Highlight ╰ TX Text Control .NET for Windows Forms
╰ TXTextControl Namespace
╰ TrackedChange Class
╰ HighlightMode Property
Gets or sets a value indicating whether the tracked change is highlighted. property to Always
or Never
according to the state of _isMarkupVisible
. Only deleted text will be displayed which is checked using the Change ╰ TX Text Control .NET for Windows Forms
╰ TXTextControl Namespace
╰ TrackedChange Class
╰ ChangeKind Property
Gets the kind of change. property.
As each tracked change object can be adjusted separately, you can also define other rules to display changes based on the time stamp, the user, the type of the change or the text itself.