# Tracked Changes: Toggle Markup

> Tracked changes is also known as red-lining - a way to track changes done by users to a document. Displaying the changes in various colors can be distracting. This demo code shows how to turn the rendering of the markup on and off.

- **Author:** Bjoern Meyer
- **Published:** 2021-04-07
- **Modified:** 2025-11-16
- **Description:** Tracked changes is also known as red-lining - a way to track changes done by users to a document. Displaying the changes in various colors can be distracting. This demo code shows how to turn the rendering of the markup on and off.
- **2 min read** (207 words)
- **Tags:**
  - ASP.NET
  - Tracked Changes
  - Windows Forms
  - WPF
- **Web URL:** https://www.textcontrol.com/blog/2021/04/07/tracked-changes-toggle-markup/
- **LLMs URL:** https://www.textcontrol.com/blog/2021/04/07/tracked-changes-toggle-markup/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2021/04/07/tracked-changes-toggle-markup/llms-full.txt

---

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.

![Toggle tracked changes](https://s1-www.textcontrol.com/assets/dist/blog/2021/04/07/a/assets/change.webp "Toggle tracked changes")

The following code uses a variable `_isMarkupVisible` that defines whether the markup should be rendered or not. In the 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 TrackedChange objects to set the HighlightMode property to `Always` or `Never` according to the state of `_isMarkupVisible`. Only deleted text will be displayed which is checked using the ChangeKind 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.

---

## About Bjoern Meyer

As CEO, Bjoern is the visionary behind our strategic direction and business development, bridging the gap between our customers and engineering teams. His deep passion for coding and web technologies drives the creation of innovative products. If you're at a tech conference, be sure to stop by our booth - you'll most likely meet Bjoern in person. With an advanced graduate degree (Dipl. Inf.) in Computer Science, specializing in AI, from the University of Bremen, Bjoern brings significant expertise to his role. In his spare time, Bjoern enjoys running, paragliding, mountain biking, and playing the piano.

- [LinkedIn](https://www.linkedin.com/in/bjoernmeyer/)
- [X](https://x.com/txbjoern)
- [GitHub](https://github.com/bjoerntx)

---

## Related Posts

- [Powerful Extension Methods to Handle Tracked Changes](https://www.textcontrol.com/blog/2019/02/14/extension-methods-to-handle-tracked-changes/llms.txt)
- [TXTextControl.Markdown.Core 34.1.0-beta: Work with Full Documents, Selection, and SubTextParts](https://www.textcontrol.com/blog/2026/04/14/txtextcontrol-markdown-core-34-1-0-beta-work-with-full-documents-selection-and-subtextparts/llms.txt)
- [TX Spell .NET 11.0 SP1 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2026/04/08/tx-spell-net-11-0-sp1-is-now-available/llms.txt)
- [TX Text Control 34.0 SP2 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2026/02/18/tx-text-control-34-0-sp2-is-now-available/llms.txt)
- [TX Text Control 34.0 SP1 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2025/12/03/tx-text-control-34-0-sp1-is-now-available/llms.txt)
- [Introducing TX Text Control 34.0: Your Next Leap in Document Processing](https://www.textcontrol.com/blog/2025/11/10/introducing-tx-text-control-34-0-your-next-leap-in-document-processing/llms.txt)
- [Sneak Peek: TX Text Control 34.0 Coming November 2025](https://www.textcontrol.com/blog/2025/10/02/sneak-peek-tx-text-control-34-0-coming-november-2025/llms.txt)
- [TX Text Control 33.0 SP3 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2025/08/14/tx-text-control-33-0-sp3-is-now-available/llms.txt)
- [TX Text Control 33.0 SP2 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2025/06/18/tx-text-control-33-0-sp2-is-now-available/llms.txt)
- [Document Lifecycle Optimization: Leveraging TX Text Control's Internal Format](https://www.textcontrol.com/blog/2025/05/16/document-lifecycle-optimization-leveraging-tx-text-controls-internal-format/llms.txt)
- [Expert Implementation Services for Legacy System Modernization](https://www.textcontrol.com/blog/2025/05/07/expert-implementation-services-for-legacy-system-modernization/llms.txt)
- [Service Pack Releases: What's New in TX Text Control 33.0 SP1 and 32.0 SP5](https://www.textcontrol.com/blog/2025/05/07/service-pack-releases-whats-new-in-tx-text-control-33-0-sp1-and-32-0-sp5/llms.txt)
- [Top 5 Real-World Applications for TX Text Control Document Processing Libraries](https://www.textcontrol.com/blog/2025/04/01/top-5-real-world-applications-for-tx-text-control-document-processing-libraries/llms.txt)
- [DWX Developer Week Moves to Mannheim - And Text Control Is on Board!](https://www.textcontrol.com/blog/2025/03/19/dwx-developer-week-moves-to-mannheim-and-tx-text-control-is-on-board/llms.txt)
- [The Wait is Over: TX Text Control for Linux is Officially Here](https://www.textcontrol.com/blog/2025/03/12/the-wait-is-over-tx-text-control-for-linux-is-officially-here/llms.txt)
- [Full .NET 9 Support in Text Control .NET Components for ASP.NET Core, Windows Forms, and WPF](https://www.textcontrol.com/blog/2024/11/11/full-net-9-support-in-text-control-net-components-for-asp-net-core-windows-forms-and-wpf/llms.txt)
- [Toggle Field Codes in TX Text Control](https://www.textcontrol.com/blog/2024/11/07/toggle-field-codes-in-tx-text-control/llms.txt)
- [TX Text Control 32.0 Service Pack 4 Released](https://www.textcontrol.com/blog/2024/09/02/tx-text-control-32-0-service-pack-4-released/llms.txt)
- [Service Pack 3: MailMerge Supports SVG Images](https://www.textcontrol.com/blog/2024/04/29/service-pack-3-mailmerge-supports-svg-images/llms.txt)
- [TX Text Control 32.0 Service Pack 3 Released](https://www.textcontrol.com/blog/2024/04/29/tx-text-control-32-0-service-pack-3-released/llms.txt)
- [Electronic Invoicing will Become Mandatory in Germany in 2025](https://www.textcontrol.com/blog/2024/04/10/electronic-invoicing-will-become-mandatory-in-germany-in-2025/llms.txt)
- [Inserting MergeBlocks with the DataSourceManager and Applying Table Styles in C#](https://www.textcontrol.com/blog/2024/04/09/inserting-mergeblocks-with-the-datasourcemanager-and-applying-table-styles-in-csharp/llms.txt)
- [The Power of SubTextParts: Typical Use Cases](https://www.textcontrol.com/blog/2024/02/09/the-power-of-subtextparts-typical-use-cases/llms.txt)
- [Renaming Merge Blocks and Merge Fields Programmatically in C#](https://www.textcontrol.com/blog/2024/02/08/renaming-merge-blocks-and-merge-fields-programmatically-in-csharp/llms.txt)
- [Encapsulating TX Text Control in Class Libraries](https://www.textcontrol.com/blog/2024/01/09/encapsulating-tx-text-control-in-class-libraries/llms.txt)
