TX Text Control .NET for Windows Forms

Create Your First Windows Forms Application

Topic

You build a word processor in a Windows Forms application: a new .NET project, the TX Text Control NuGet package, and a TextControl with a ribbon, rulers and a status bar that the designer adds for you. No code is needed until the last step, which loads a document when the form opens.

Prerequisites

  • Visual Studio on Windows. Version 34.0 has been tested with Visual Studio 2026. See Visual Studio.
  • The setup of TX Text Control .NET for Windows Forms 34.0, the full or the trial version, installed on your machine. It provides the package source Text Control Offline Packages and the designers. See Installing the Product.

Create the Project

  1. Open Visual Studio and create a new project.

  2. Select C# from the Languages list, Windows from the Platform list and Desktop as the Project Type. The steps in the designer are the same for a Visual Basic project, which you get by selecting Visual Basic instead; the code later on this page is C#.

  3. Select the project template Windows Forms App and click Next.

    The Create a new project dialog of Visual Studio with the filters C#, Windows and Desktop and the template Windows Forms App selected.

  4. Enter a project name and click Next.

  5. Select .NET 8 or higher as the Framework, for example .NET 10, and click Create.

    The Additional information page of Visual Studio for the Windows Forms App template, with .NET 8.0 (Long Term Support) selected in the Framework list.

The template Windows Forms App (.NET Framework) creates a .NET Framework project instead, which Create a .NET Framework Application covers.

Install the NuGet Package

  1. Select the project in Solution Explorer and choose Project > Manage NuGet Packages....

  2. Select Text Control Offline Packages in the Package source list and click Browse.

  3. Select TXTextControl.TextControl.WinForms.SDK and click Install.

    The NuGet Package Manager of Visual Studio with Text Control Offline Packages as the package source and TXTextControl.TextControl.WinForms.SDK selected, here in version 32.0.2.

The package contains the controls, the document engine and your license. See Package Overview for what it adds to the project.

Add the Editor to the Form

  1. Open Form1 in the designer from Solution Explorer.

  2. In the Toolbox, open the tab TX Text Control 34.0, select TextControl and draw the control onto the form.

    The Visual Studio Toolbox with the tab TX Text Control 32.0 open and the item TextControl marked, followed by ButtonBar, RulerBar, StatusBar and the ribbon tabs.

  3. Click the smart tag in the upper right corner of the TextControl. In the Wizards group, click Add a Ribbon, Add a StatusBar, Add a Ruler and Add a Vertical Ruler.

    A TextControl on Form1 in the designer with its TextControl Tasks smart tag open, showing the Appearance, Information and Wizards groups with Add a Ribbon, Add a ButtonBar, Add a StatusBar, Add a Ruler, Add a Vertical Ruler, the three sidebar wizards and Arrange Controls Automatically.

  4. Click Arrange Controls Automatically. The controls are now connected to the TextControl and docked so that they fill the form.

Add the Ribbon Tabs

  1. Select the ribbon by clicking its blue File tab title.

  2. Click the smart tag in the upper right corner of the ribbon.

  3. Click Add a RibbonFormattingTab, Add a RibbonInsertTab, Add a RibbonPageLayoutTab, Add a RibbonViewTab and Add a RibbonProofingTab.

    The form in the designer with the ribbon tabs File, Home, Insert, Page Layout, View and Proofing, and the Ribbon Tasks smart tag listing the Add a Ribbon...Tab commands.

Each tab is a ready-made set of commands for the editor. Built-in Ribbon Tabs describes all predefined tabs.

Run the Application

Press F5. The form shows a word processor:

  • The ribbon with the File tab and the tabs Home, Insert, Page Layout, View and Proofing. Home contains the groups Clipboard, Font, Paragraph, Styles and Editing.
  • A horizontal and a vertical ruler, which show and set margins, indents and tabs.
  • The document in page view, starting with the name of the control, textControl1.
  • A status bar with the page, line and column of the input position, the language and a zoom slider.

The running Windows Forms application with the Home tab of the ribbon, the horizontal and vertical rulers, the page with the text textControl1 and the status bar with the language and a zoom slider.

Type some text, format it with the ribbon and resize the form: the editor and its bars follow.

Load a Document When the Form Opens

The following code in Form1.cs shows pages like a printed document and loads a DOCX file when the form opens:

using System;
using System.Windows.Forms;
using TXTextControl;

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        Load += Form1_Load;
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        // Show pages like a printed document
        textControl1.ViewMode = ViewMode.PageView;

        // Replace the contents with a DOCX file
        textControl1.Load("document.docx", StreamType.WordprocessingML);
    }
}

Keep the namespace that Visual Studio created around the class. Copy a file named document.docx into the output folder of the project, such as bin\Debug\net10.0-windows, or use its full path.

The code works as follows:

  • Load += Form1_Load connects the handler to the Load event of the form.
  • ViewMode sets how the document is displayed. PageView shows pages with gaps and a background.
  • Load replaces the contents of the editor with the file. StreamType.WordprocessingML is the DOCX format.

Troubleshooting

  • The tab TX Text Control 34.0 is missing. In a .NET project, the tab appears after the package is installed and a form is open in the designer. The setup has to be installed for the designers to work. See Visual Studio Toolbox and Designer.
  • Text Control Offline Packages is not in the Package source list. See Configuring Package Sources.
  • License questions. In a .NET project, the package brings the license, and nothing else is needed. See Development Licenses.

Next Steps