# MailMerge: Creating Shipping Labels Using TX Text Control

> Shipping labels are created with TX Text Control by designing a two-column template in TX Words, setting Avery label page margins, inserting merge fields from an XML data source, and calling MergeBlocks in C# code. The MailMerge component generates labels for each data row automatically.

- **Author:** Bjoern Meyer
- **Published:** 2012-11-23
- **Modified:** 2026-07-17
- **Description:** Shipping labels are created with TX Text Control by designing a two-column template in TX Words, setting Avery label page margins, inserting merge fields from an XML data source, and calling MergeBlocks in C# code. The MailMerge component generates labels for each data row automatically.
- **4 min read** (692 words)
- **Tags:**
  - Sample
- **Web URL:** https://www.textcontrol.com/blog/2012/11/23/mailmerge-creating-shipping-labels-using-tx-text-control/
- **LLMs URL:** https://www.textcontrol.com/blog/2012/11/23/mailmerge-creating-shipping-labels-using-tx-text-control/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2012/11/23/mailmerge-creating-shipping-labels-using-tx-text-control/llms-full.txt

---

![TX Text Control shipping labels](https://s1-www.textcontrol.com/assets/dist/blog/2012/11/23/a/assets/shipping_label.webp "TX Text Control shipping labels")Creating labels for mailings, shipping or labeling is a common task for reporting tools. TX Text Control's MailMerge component gives you powerful features to create such labels or to print content on pre-printed Avery labels.

Using TX Text Control, creating labels is a very easy task. The following tutorial shows the details:

1. In a first step, the template must be created. Therefore, the shipped template designer **TX Text Control Words** can be used or you can reuse existing MS Word documents. In this tutorial, a label template is created from scratch in TX Text Control Words.
    
    Open TX Text Control Words and create a new document. Open the *Page Layout* ribbon tab and set the number of columns to 2.
    
    ![TX Text Control shipping labels](https://s1-www.textcontrol.com/assets/dist/blog/2012/11/23/a/assets/step_1.webp "TX Text Control shipping labels")
2. Set the page margins to the specific margins of your full sheet label paper. Many Avery® labels have a top and bottom margin of 0.5" and a left and right border of 0.156".
    
    ![TX Text Control shipping labels](https://s1-www.textcontrol.com/assets/dist/blog/2012/11/23/a/assets/step_2.webp "TX Text Control shipping labels")
3. Insert a table with 1 row and 1 column and set the minimum height to the vertical label dimension. Insert the table using the *Table* button of the *Insert* ribbon tab. Set the input position inside the table and open the *Properties* dialog box of the *Table Tools* contextual ribbon tab. Confirm with *OK*.
    
    ![TX Text Control shipping labels](https://s1-www.textcontrol.com/assets/dist/blog/2012/11/23/a/assets/step_3.webp "TX Text Control shipping labels")
4. Now you can start designing your label. In our sample, a nested table is used to arrange different textual label sections:
    
    ![TX Text Control shipping labels](https://s1-www.textcontrol.com/assets/dist/blog/2012/11/23/a/assets/step_4.webp "TX Text Control shipping labels")
5. In a last step, merge fields must be added for the variable label data. Open the *Mailings* ribbon tab and insert merge fields at the desired positions. Set the cursor to a specific input position and click the *Insert Merge Field* button. In the opened dialog box, type in a name for the field. In this sample, the data source is an XML file with 3 fields per label:
    
    ```
    <label>
        <name>Jack Ballmer</name>
        <company>Microsoft</company>
        <package_weight>72</package_weight>
    </label>
    ```
    
    Analogically, the merge field names are: **name**, **company** and **package\_weight**.
    
    ![TX Text Control shipping labels](https://s1-www.textcontrol.com/assets/dist/blog/2012/11/23/a/assets/step_5.webp "TX Text Control shipping labels")The final template should look like this:
    
    ![TX Text Control shipping labels](https://s1-www.textcontrol.com/assets/dist/blog/2012/11/23/a/assets/step_5_2.webp "TX Text Control shipping labels")Save the template as DOC, DOCX, RTF or in the internal TX Text Control format.
6. You need a TextControl and a MailMerge instance in your .NET application. Refer to the documentation to learn how to create and connect these controls:
    
    [Connecting MailMerge to TextControl](https://docs.textcontrol.com/textcontrol/windows-forms/article.winforms.mailmerge.htm)
    
    Two easy steps are required to create the labels. First, the template must be loaded into TX Text Control:
    
    ```
    TXTextControl.LoadSettings ls = new TXTextControl.LoadSettings();
    ls.ApplicationFieldFormat = TXTextControl.ApplicationFieldFormat.MSWord;
    textControl1.Load("template.docx",
        TXTextControl.StreamType.WordprocessingML, ls);
    ```
    
    Loading the XML data source in order to fill a DataSet and to merge the document is the second step:
    
    ```
    DataSet ds = new DataSet();
    ds.ReadXml("data.xml");
    mailMerge1.MergeBlocks(ds);
    mailMerge1.Merge(ds.Tables[0], false);
    ```

This is all you need to create pixel perfect labels. Based on the number of data rows, the number of labels are created:

![TX Text Control shipping labels](https://s1-www.textcontrol.com/assets/dist/blog/2012/11/23/a/assets/step_6.webp "TX Text Control shipping labels")Try it out and [download the template and the Visual Studio project](https://s1-www.textcontrol.com/assets/dist/blog/2012/11/23/a/assets/tx_labels.zip). A [trial](https://www.textcontrol.com/product/tx-text-control-dotnet-winforms/download/) or full version of TX Text Control .NET for Windows Forms X8 is required to run this application.

---

## 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

- [Create a Table of Contents in Windows Forms using C#](https://www.textcontrol.com/blog/2023/01/23/create-toc-in-windows-forms/llms.txt)
- [Official TX Text Control .NET Sample Applications Are Now Hosted on GitHub](https://www.textcontrol.com/blog/2023/01/08/official-tx-text-control-net-sample-applications-are-now-hosted-on-github/llms.txt)
- [Detect Toggle Button Changes Using a MutationObserver](https://www.textcontrol.com/blog/2021/11/11/detect-toggle-button-changes-using-a-mutationobserver/llms.txt)
- [Two Ways to Restart Numbered Lists in TX Text Control](https://www.textcontrol.com/blog/2021/11/03/two-ways-to-restart-numbered-lists/llms.txt)
- [Zoom Tricks: Disabling CTRL + MOUSE WHEEL and More](https://www.textcontrol.com/blog/2020/12/09/zoom-tricks-disabling-ctrl-mouse-wheel-and-more/llms.txt)
- [AutoCorrect Using TX Text Control and TX Spell .NET](https://www.textcontrol.com/blog/2017/08/17/autocorrect-using-tx-text-control-and-tx-spell-net/llms.txt)
- [Creating Conference Badges with Text Control Reporting](https://www.textcontrol.com/blog/2017/02/14/creating-conference-badges-with-text-control-reporting/llms.txt)
- [Using Custom Document Properties to Store Additional Document Information](https://www.textcontrol.com/blog/2017/02/09/using-custom-document-properties-to-store-additional-document-information/llms.txt)
- [Use SubTextParts to Protect Document Parts](https://www.textcontrol.com/blog/2015/12/29/use-subtextparts-to-protect-document-parts/llms.txt)
- [Reporting: Styling the DocumentViewer for ASP.NET](https://www.textcontrol.com/blog/2015/06/14/reporting-styling-the-documentviewer-for-aspnet/llms.txt)
- [Reporting: Merging MS Word Documents with DocVariables](https://www.textcontrol.com/blog/2015/06/10/reporting-merging-ms-word-documents-with-docvariables/llms.txt)
- [TextControl.Web: Determine when a Document Has Been Completely Loaded](https://www.textcontrol.com/blog/2015/06/09/textcontrolweb-determine-when-a-document-has-been-completely-loaded/llms.txt)
- [TextControl.Web: Adding Custom Ribbon Tabs](https://www.textcontrol.com/blog/2015/05/29/textcontrolweb-adding-custom-ribbon-tabs/llms.txt)
- [Building a Touch-enabled Button Bar with Javascript](https://www.textcontrol.com/blog/2015/05/27/building-a-touch-enabled-button-bar-with-javascript/llms.txt)
- [TextControl.Web: Inserting Merge Fields Using Javascript](https://www.textcontrol.com/blog/2015/05/16/textcontrolweb-inserting-merge-fields-using-javascript/llms.txt)
- [MailMerge: Merge Hyperlinks into Merge Fields](https://www.textcontrol.com/blog/2015/05/15/mailmerge-merge-hyperlinks-into-merge-fields/llms.txt)
- [Mail Merge: Suppress Lines with Empty Merge Fields](https://www.textcontrol.com/blog/2014/08/01/mail-merge-suppress-lines-with-empty-merge-fields/llms.txt)
- [Interactive Spelling Suggestions Using TX Spell .NET](https://www.textcontrol.com/blog/2014/07/30/interactive-spelling-suggestions-using-tx-spell-net/llms.txt)
- [Alternate Row Colors Using NEXT Fields](https://www.textcontrol.com/blog/2013/12/30/alternate-row-colors-using-next-fields/llms.txt)
- [Loading Dictionaries Dynamically in TX Spell .NET](https://www.textcontrol.com/blog/2013/12/20/loading-dictionaries-dynamically-in-tx-spell-net/llms.txt)
- [Restart the Page Numbering Fields Per Section](https://www.textcontrol.com/blog/2013/11/08/restart-the-page-numbering-fields-per-section/llms.txt)
- [TX Barcode .NET: Test the Barcode Engine Live!](https://www.textcontrol.com/blog/2013/07/10/tx-barcode-net-test-the-barcode-engine-live/llms.txt)
- [SD Times .NET Component Buyers Guide 2013: Simplify Report Creation](https://www.textcontrol.com/blog/2013/06/06/sd-times-net-component-buyers-guide-2013-simplify-report-creation/llms.txt)
- [Inserting MS Word Compatible Page Number Fields](https://www.textcontrol.com/blog/2013/05/30/inserting-ms-word-compatible-page-number-fields/llms.txt)
- [Using RulerBars in Separate Windows](https://www.textcontrol.com/blog/2012/11/20/using-rulerbars-in-separate-windows/llms.txt)
