# Comments and Tracked Changes

> Process comments and tracked changes in Windows Forms: comment on found text, accept one reviewer's changes, strip all markup and compare two versions.

- **Product:** TX Text Control .NET for Windows Forms
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Text Control .NET for Windows Forms > Document Processing > Comments and Tracked Changes
- **2341 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/comments-changes/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/comments-changes/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/comments-changes/llms-full.txt

---

Contracts and reports go back and forth between authors and reviewers. Reviewers leave comments on pieces of text, and with track changes turned on, every insertion and deletion stays marked with its author and time until someone accepts or rejects it. In a Windows Forms application, the `TextControl` records both while the user types, and your code turns tracking on, adds comments, lists what reviewers did and accepts or rejects changes, for example before a final version is saved.

The examples are handlers in *Form1.cs* with the `TextControl` named `textControl1`. They process the comments and changes of a whole document. How users comment and review with the ribbon, and how single comments and changes are added, listed and removed in code, is described in [Track Changes](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/track-changes/llms-full.txt) and [Comments](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/comments/llms-full.txt) in the Document Editor section.

### How Comments and Tracked Changes Work

A comment is a [CommentedText](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/commentedtext/llms-full.txt) object and a tracked change a [TrackedChange](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/trackedchange/llms-full.txt) object, both with the first name of [TextControl.UserNames](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/usernames-property/llms-full.txt) as their author, as [How Comments Work](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/comments/#how-comments-work) and [How Track Changes Works](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/track-changes/#how-track-changes-works) describe. For processing a whole document, one fact matters most: [TextControl.Comments](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/comments-property/llms-full.txt) and [TextControl.TrackedChanges](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/trackedchanges-property/llms-full.txt) contain only the comments and changes of the text part with the input focus: the main text, a text frame, or a header or footer. The handlers below therefore loop through all text parts.

### Track the Changes of the User

[IsTrackChangesEnabled](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/istrackchangesenabled-property/llms-full.txt) turns tracking on and off, and `UserNames` names the author of new changes. [Set the Author and Turn On Tracking](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/track-changes/#set-the-author-and-turn-on-tracking) shows both, and [Handle Changes That Can't Be Tracked](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/track-changes/#handle-changes-that-can-t-be-tracked) the `CannotTrackChange` event for operations such as deleting a table column.

### Add a Comment

[CommentCollection.Add](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/commentcollection/add-method/llms-full.txt) adds a [CommentedText](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/commentedtext/constructor/llms-full.txt) that your code creates, as [Add Comments in Code](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/comments/#add-comments-in-code) shows. To comment on text that your code has found, note that [TextControl.Find](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/find-method/llms-full.txt) returns a zero-based position, while the `CommentedText` constructor expects a one-based start: pass `position + 1`.

### Accept or Reject Tracked Changes

[TrackedChangeCollection.Remove](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/trackedchangecollection/remove-method/llms-full.txt) is the only way to remove a tracked change: with `true`, the change is accepted and the text stays as it is; with `false`, it is rejected, inserted text is removed and deleted text is restored. The following handler accepts the changes of one reviewer and rejects all others in every part of the document. It needs `using System.Collections.Generic;` and `using System.Linq;` at the top of *Form1.cs*:

```csharp
private void acceptReviewerButton_Click(object sender, EventArgs e)
{
    string trustedAuthor = "Alice Johnson";

    foreach (TXTextControl.IFormattedText textPart in textControl1.TextParts)
    {
        // Copy the changes first, because Remove changes the collection
        List<TXTextControl.TrackedChange> changes = textPart.TrackedChanges.Cast<TXTextControl.TrackedChange>().ToList();

        foreach (TXTextControl.TrackedChange change in changes)
        {
            textPart.TrackedChanges.Remove(change, change.UserName == trustedAuthor);
        }
    }
}
```

[TextControl.TextParts](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/textparts-property/llms-full.txt) returns the main text, the text frames and the headers and footers, each an [IFormattedText](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/iformattedtext/llms-full.txt) with its own [TrackedChanges](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/iformattedtext/trackedchanges-property/llms-full.txt) and [Comments](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/iformattedtext/comments-property/llms-full.txt).

### Remove Comments Before Sending a Document

A document that leaves the company should often carry neither comments nor markup. The following handler accepts all changes, removes all comments and saves the result as PDF:

```csharp
private void finalizeButton_Click(object sender, EventArgs e)
{
    textControl1.IsTrackChangesEnabled = false;

    foreach (TXTextControl.IFormattedText textPart in textControl1.TextParts)
    {
        // Number 1 is always the first remaining change or comment
        while (textPart.TrackedChanges.Count > 0 && textPart.TrackedChanges.Remove(textPart.TrackedChanges[1], true)) { }
        while (textPart.Comments.Count > 0 && textPart.Comments.Remove(textPart.Comments[1])) { }
    }

    textControl1.Save("contract-final.pdf", TXTextControl.StreamType.AdobePDF);
}
```

[CommentCollection.Remove](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/commentcollection/remove-method/llms-full.txt) removes a comment with its replies and keeps the commented text. Both `Remove` methods return `false` if nothing was removed, which ends the loops.

### Show the Built-In Dialog Boxes and React to Changes

The modeless [CommentsDialog](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/commentsdialog/llms-full.txt) and [TrackedChangesDialog](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/trackedchangesdialog/llms-full.txt) list all comments or changes for the user, and events such as `CommentCreated` and `TrackedChangeCreated` report what happens to them. [React to Comments](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/comments/#react-to-comments) and [React to Tracked Changes](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/track-changes/#react-to-tracked-changes) list the events.

The blog article [Inspect and Process Track Changes in DOCX Documents with TX Text Control with .NET C#](https://www.textcontrol.com/blog/2026/03/10/inspect-and-process-track-changes-in-docx-documents-with-tx-text-control-with-dotnet-csharp/) filters changes by author, kind and time with LINQ.

### Compare Two Documents

Tracked changes also show the differences between two versions of a document. Text Control's comparison sample loads the original and the revised version into two `TextControl` instances, compares their paragraphs sentence by sentence and word by word, and writes every differing word of the revised version into the original while [IsTrackChangesEnabled](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/istrackchangesenabled-property/llms-full.txt) is `true`. The original then shows each difference as a deletion and an insertion, which the reviewer accepts or rejects as described above:

![A Windows Forms window with two documents side by side and a Compare button; the left document shows replaced words as red deleted and inserted text.](https://docs.textcontrol.com/assets/img/tx-text-control-dotnet-winforms/document-comparison-changes.3349ecab.webp)

The comparison works on [Paragraphs](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/paragraphs-property/llms-full.txt), their `Text` and `Start`, and the `Selection` of the original, and the blog notes that it can be rewritten for `ServerTextControl` instances. It compares the paragraphs in their order and the words of each sentence by their position. The blog article [Word-based Document Comparison and Track Changes Using TX Text Control and C#](https://www.textcontrol.com/blog/2024/05/02/word-based-document-comparison-and-track-changes-using-tx-text-control-and-c-sharp/) explains the algorithm, and the complete sample is in the GitHub repository [TXTextControl.Windows.Forms.Comparison](https://github.com/TextControl/TXTextControl.Windows.Forms.Comparison).

### Next Steps

- [Track Changes](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/track-changes/llms-full.txt): track changes with the ribbon and the sidebar.
- [Comments](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/comments/llms-full.txt): comment with the ribbon and the sidebar.
- [Document Protection and User Permissions](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/security/document-protection/llms-full.txt): the users and editable regions of protected documents.
- [Saving and Converting Documents](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/saving-converting/llms-full.txt): save the final version.

---

## Nearby

- **Previous:** [Forms and Conditional Instructions](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/form-fields/llms-full.txt)
- **Next:** [XML Processing](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/xml/llms-full.txt)
