The TXText ╰ TX Text Control .NET for Windows Forms
╰ DocumentServer Namespace
╰ MailMerge Class
The MailMerge class is a .NET component that can be used to effortlessly merge template documents with database content in .NET projects, such as ASP.NET web applications, web services or Windows services. provides an extensible framework to inject custom logic to the merge process. The TXText ╰ TX Text Control .NET for Windows Forms
╰ DocumentServer Namespace
╰ MailMerge Class
╰ FieldMerged Event
Occurs when a field has been merged. can be used to manipulate the results, but also gives access to the surrounding instance of the TXText ╰ TX Text Control .NET for Windows Forms
╰ TXTextControl Namespace
╰ TableCell Class
An instance of the TableCell class represents a single cell of a table in a Text Control document. .
This combination allows creative implementations such as conditional table cell colors based on specific filter instructions.
In the following sample, the table cell Qty should be highlighted red, if quantity is higher than 10, otherwise it should be green.
These conditions can be adjusted in the following dialog:
When merging the document, the conditions are evaluated in the custom events:
The class CellFilterInstructions contains the instructions for the custom filter:

This class is serialized as JSON and stored in the TXText ╰ TX Text Control .NET for Windows Forms
╰ TXTextControl Namespace
╰ TableCell Class
╰ Name Property
Gets or sets the cell's name. . When a new dialog is opened, the JSON is deserialized and passed to the dialog. After changes are made, the object is stored as a serialized JSON string back in the TableCell.Name property.

In the FieldMerging event, the instructions are evaluated and the custom background color is applied to the cell that is returned in the event arguments:

Test this sample on your own and download the GitHub repository.