Creating mail merge templates including a preview functionality


Well-known member
Oct 9, 2009
Programming Experience
Because of the new FieldAdapter class, MS Word compatible merge fields can be inserted easily into a document. Using the Windows Forms version of TX Text Control, a template designer can be easily built and deployed royalty-free.

In the shipped samples, TX Text Control demonstrates how to create templates by inserting the fields directly using the ApplicationField collection. This article describes how to create templates using the adapter fields. Additionally, it shows how to preview the template with the real data coming from a database.

This approach follows the same logic of creating a template like the shipped 'closed source' TX Template Designer:

- Open a database
- Select a table
- Insert fields


1. First, click on Open Database... and browse for an XML database file. A sample file comes with this project. If the XML database could be loaded properly, the contained tables are listed in the first combobox.

2. Select one of the listed tables. All column names will be added to the items of the second combobox.

3. The column names are used as field names of the inserted merge fields. If an item is selected, click Add field to insert the merge field into the document.

4. The loaded database is used to get the possible fields that can be used in the template. Additionally, the contained data rows can be used to preview the merged document. Click on Preview to enable the preview functionality.

Using the arrow buttons, it is possible to navigate through the data rows of the current table to preview all rows. You are able to use this nice approach as your basis for your own template designer.

Download the project and sample database file here (Visual Studio 2008 and at least a TX Text Control .NET 15.0 trial version is required):

Download Sample

About TX Text Control:

TX Text Control was originally released in 1991, since then more than 40,000 copies have been sold. Starting off as a single, small DLL, TX Text Control has made its way through 16-bit DLL and VBX versions to today‘s Enterprise edition with its .NET and ActiveX components. The recent addition to the family, TX Text Control .NET Server, offers all of TX Text Control advanced word processing functionality in an easy-to-use server-side .NET component. Customers benefit from these years of experience, large user base, and at the same time, appreciate developing with a mature, reliable product.

Contact Informations:

North & South America:
Phone: +1 704-370-0110
Phone: +1 877-462-4772 (toll free)

Phone: +49 421 335 910

Asia Pacific:
Phone: +886 2-2797-8508
Top Bottom