# Mail Merge and Reporting

> Mail merge in Windows Forms: design templates in the Reporting tab, merge data with MailMerge, and find the pages on fields, blocks, styling and events.

- **Product:** TX Text Control .NET for Windows Forms
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Text Control .NET for Windows Forms > Mail Merge and Reporting
- **1517 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/llms-full.txt

---

Invoices, letters, contracts and reports that share a layout but differ in their data come from one template and a merge. In a Windows Forms application, both halves live in the same form: users design templates in the `TextControl` with the **Reporting** ribbon tab, and the `MailMerge` component fills them with data, in the visible editor or in the background. Read on for the way from the reporting model to data sources, fields and blocks, conditions, formatting, the template designer and the events of a merge.

If you haven't merged a template yet, start with the tutorials of [Getting Started: Mail Merge](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/mail-merge/llms-full.txt). [MailMerge](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/overview/components/mailmerge/llms-full.txt) in the Overview introduces the component. Mail merge is part of the Professional and Enterprise editions, as [Editions and Feature Availability](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/overview/editions/llms-full.txt) lists.

### How Mail Merge Works

A merge brings three parts together:

- **The template** is a document designed in the **Reporting** tab of your application, in MS Word or in code. It contains merge fields for single values, merge blocks for repeating and optional parts, special fields such as `IF` and `INCLUDETEXT`, and placeholders for images and barcodes.
- **The data** comes as business objects, a `DataSet`, JSON or XML, in the structure the document needs. Its names match the names of the fields and blocks.
- **`MailMerge`** fills the template held by a `TextControl` or a `ServerTextControl` with the data. The result is shown in the editor, saved as PDF, DOCX or another format, or printed, as one document or one document per record.

The template holds the layout and the rules, such as formats and filters, so the merge code doesn't change when a designer changes the template.

![The Reporting tab with the groups Data Source, Merge Fields, Merge Blocks and View](https://docs.textcontrol.com/assets/img/tx-text-control-dotnet-winforms/ribbon-reporting-tab.f35a177d.webp)

### Find the Right Page

| If you want to | Read |
|---|---|
| Understand the reporting model, merge in the editor or in the background, create one document per record | [Overview](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/overview/llms-full.txt) |
| Merge business objects, DataSets, JSON or XML, or connect a database in the designer | [Data Sources](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/data-sources/llms-full.txt) |
| Format numbers and dates, add text before and after a value, insert date fields | [Merge Fields](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/fields/llms-full.txt) |
| Repeat table rows or sections for each record | [Merge Blocks](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/blocks/llms-full.txt) |
| Build master-detail reports with blocks inside blocks | [Nested Blocks and Master-Detail Reports](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/nested-blocks/llms-full.txt) |
| Reuse terms, letterheads or address blocks in many templates | [Subtemplates](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/subtemplates/llms-full.txt) |
| Merge logos, photos, QR codes, barcodes and charts | [Images and Barcodes](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/images-barcodes/llms-full.txt) |
| Include text and sections only when the data calls for them | [Conditional Content](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/conditional-content/llms-full.txt) |
| Merge the rows of a block in order and only the rows you need | [Sorting and Filtering](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/sorting-filtering/llms-full.txt) |
| Color rows, highlight values or calculate totals in merged tables | [Formatting and Styling](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/styling/llms-full.txt) |
| Design, store and test templates that hold up with real data | [Template Design](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/template-design/llms-full.txt) |
| Know every button and dialog box of the Reporting tab, or open them from your code | [Reporting Ribbon and Dialog Boxes](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/ribbon-dialogs/llms-full.txt) |
| Show users the merged result while they design | [Template Preview](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/template-preview/llms-full.txt) |
| Follow, change or cancel a merge in its events | [Merge Events](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/events/llms-full.txt) |

### Where to Start

1. [Overview](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/overview/llms-full.txt): templates, data and where the merge runs.
2. [Data Sources](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/data-sources/llms-full.txt): the data your application merges.
3. [Merge Fields](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/fields/llms-full.txt) and [Merge Blocks](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/blocks/llms-full.txt): the elements of every template.
4. [Reporting Ribbon and Dialog Boxes](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/ribbon-dialogs/llms-full.txt) and [Template Design](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/template-design/llms-full.txt): the designer your users work with.

### Pages in This Section

- [Overview](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/overview/llms-full.txt): the reporting model, pre-shaped data and one document per record.
- [Data Sources](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/data-sources/llms-full.txt): objects, DataSets, JSON, XML and configuration files.
- [Merge Fields](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/fields/llms-full.txt): formats, text before and after a value, date and form fields.
- [Merge Blocks](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/blocks/llms-full.txt): repeating parts of a template.
- [Nested Blocks and Master-Detail Reports](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/nested-blocks/llms-full.txt): blocks inside blocks.
- [Subtemplates](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/subtemplates/llms-full.txt): documents included with `INCLUDETEXT` fields.
- [Images and Barcodes](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/images-barcodes/llms-full.txt): placeholders and charts filled from the data.
- [Conditional Content](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/conditional-content/llms-full.txt): `IF` fields, optional blocks and conditions.
- [Sorting and Filtering](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/sorting-filtering/llms-full.txt): rules that blocks store.
- [Formatting and Styling](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/styling/llms-full.txt): formatting kept from the template and set in events.
- [Template Design](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/template-design/llms-full.txt): where templates are designed, stored and tested.
- [Reporting Ribbon and Dialog Boxes](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/ribbon-dialogs/llms-full.txt): the Reporting tab, its dialog boxes and their classes.
- [Template Preview](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/template-preview/llms-full.txt): the merged result in the editor while designing.
- [Merge Events](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/events/llms-full.txt): the events of `MailMerge` and their order.

### Related Sections

- [Document Editor](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/llms-full.txt): the editor that users design templates in.
- [Document Processing](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/llms-full.txt): change merged documents with `ServerTextControl`.
- [PDF Processing](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/pdf/llms-full.txt): create PDF/A documents and forms from merged documents.
- [Mail Merge Examples](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/examples/mail-merge/llms-full.txt): the TX Words Reporting sample and other complete applications.

---

## In This Section

- [Merge Blocks](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/blocks/llms-full.txt): Merge blocks in Windows Forms: the Insert Merge Block dialog, InsertMergeBlock with paragraph blocks, GetBlockNames and the block at the input position.
- [Conditional Content](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/conditional-content/llms-full.txt): Make Windows Forms templates conditional: IF fields and IfField, optional sections as merge blocks, merging conditions, INCLUDETEXT events and FieldMerged.
- [Data Sources](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/data-sources/llms-full.txt): Choose a mail merge data source in Windows Forms: business objects, DataSets, JSON, XML or configuration files, merged with MailMerge and shown in the ribbon.
- [Merge Events](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/events/llms-full.txt): Handle MailMerge events in Windows Forms: FieldMerged, BlockMerging, BlockRowMerged and DataRowMerged, their order, designer handlers and Cancel.
- [Merge Fields](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/fields/llms-full.txt): Format merge fields in Windows Forms: the Merge Field Options dialog, MergeField number and date formats, DATE fields, FieldMerged, HTML and form fields.
- [Images and Barcodes](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/images-barcodes/llms-full.txt): Merge images, barcodes and charts in Windows Forms: named placeholders, Select Frame Data Column, TXBarcodeControl, Base64 and SVG data, chart data relations.
- [Nested Blocks and Master-Detail Reports](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/nested-blocks/llms-full.txt): Build master-detail reports in Windows Forms with nested merge blocks: the Field Navigation sidebar, ChildBlocks, nested JSON and objects, DataSet relations.
- [Overview](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/overview/llms-full.txt): How MailMerge works in Windows Forms: pre-shaped data, merging in the TextControl or a ServerTextControl, one PDF per record, LoadTemplate and Print.
- [Reporting Ribbon and Dialog Boxes](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/ribbon-dialogs/llms-full.txt): The Windows Forms RibbonReportingTab: its groups, the Insert Merge Block and field options dialogs, their DocumentServer.Windows.Forms classes and FindItem.
- [Sorting and Filtering](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/sorting-filtering/llms-full.txt): Sort and filter merge block rows in Windows Forms: the Filter and Sort dialog, FilterInstruction, SortingInstruction, Apply and block merging conditions.
- [Formatting and Styling](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/styling/llms-full.txt): Format merged documents in Windows Forms: formatting kept from the template, NEXT fields and BlockRowMerged for row colors, FieldMerged cell rules.
- [Subtemplates](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/subtemplates/llms-full.txt): Reuse headers and terms as subtemplates in Windows Forms: INCLUDETEXT fields from the Reporting tab or IncludeText, SearchPath and the IncludeTextMerging event.
- [Template Design](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/template-design/llms-full.txt): Design mail merge templates in Windows Forms: the Reporting tab or TX Words, sample data in DataSourceManager, TX or DOCX storage, layout rules and tests.
- [Template Preview](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/template-preview/llms-full.txt): Preview a mail merge template in a Windows Forms editor: DataSourceManager.Merge with MergeSettings, paging through records and restoring the template.

---

## Nearby

- **Previous:** [Content Controls and Word Form Fields](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/content-controls/llms-full.txt)
- **Next:** [Overview](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/overview/llms-full.txt)
