TX Text Control .NET for Windows Forms

Mail Merge and Reporting

Topic

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. MailMerge in the Overview introduces the component. Mail merge is part of the Professional and Enterprise editions, as Editions and Feature Availability 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

Find the Right Page

If you want toRead
Understand the reporting model, merge in the editor or in the background, create one document per recordOverview
Merge business objects, DataSets, JSON or XML, or connect a database in the designerData Sources
Format numbers and dates, add text before and after a value, insert date fieldsMerge Fields
Repeat table rows or sections for each recordMerge Blocks
Build master-detail reports with blocks inside blocksNested Blocks and Master-Detail Reports
Reuse terms, letterheads or address blocks in many templatesSubtemplates
Merge logos, photos, QR codes, barcodes and chartsImages and Barcodes
Include text and sections only when the data calls for themConditional Content
Merge the rows of a block in order and only the rows you needSorting and Filtering
Color rows, highlight values or calculate totals in merged tablesFormatting and Styling
Design, store and test templates that hold up with real dataTemplate Design
Know every button and dialog box of the Reporting tab, or open them from your codeReporting Ribbon and Dialog Boxes
Show users the merged result while they designTemplate Preview
Follow, change or cancel a merge in its eventsMerge Events

Where to Start

  1. Overview: templates, data and where the merge runs.
  2. Data Sources: the data your application merges.
  3. Merge Fields and Merge Blocks: the elements of every template.
  4. Reporting Ribbon and Dialog Boxes and Template Design: the designer your users work with.

Pages in This Section