# TextControl

> Put TextControl on a Windows Forms form with the toolbox and smart tag, set ViewMode and EditMode, format through Selection, and load, save and print documents.

- **Product:** TX Text Control .NET for Windows Forms
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Text Control .NET for Windows Forms > Overview > Components > TextControl
- **2354 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/overview/components/textcontrol/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/overview/components/textcontrol/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/overview/components/textcontrol/llms-full.txt

---

`TextControl` is the word processing control of TX Text Control .NET for Windows Forms: the area of a form in which your users write, format and print documents. What it is, what you and your users do with it, how you put it on a form and which of its members you use first are described below, together with how it differs from `ServerTextControl`.

### What TextControl Is

`TextControl` is a Windows Forms control with high-level text editing features. The class is `TXTextControl.TextControl`, derived from `System.Windows.Forms.Control`, so it behaves like any other control on a form: you dock it, anchor it, enable or disable it and handle its keyboard and mouse events. The reference documents the members `TextControl` adds; the inherited ones, such as `Dock`, `Anchor` and `Text`, are those of `Control`.

Everything a document consists of is available through properties and methods: text and paragraphs, tables, images, headers and footers, sections, fields, form fields, comments and tracked changes. Users edit these with the keyboard and the mouse, and your code reads and changes the same objects.

Unlike [ServerTextControl](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/overview/components/servertextcontrol/llms-full.txt), `TextControl` is created with the form and needs no call to `Create`. Both classes share the same programming interface for documents, so what you learn about one applies to the other.

### What You Do With It

- **Let users edit documents.** Users type, select, copy and paste text, undo and redo changes, and format characters and paragraphs. Double-clicking selects a word, dragging moves selected text, and keyboard shortcuts such as Ctrl+Z and Ctrl+Y work as in other word processors.
- **Format documents in code.** The [Selection](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/selection-property/llms-full.txt) property applies character and paragraph formatting to the selected text, and collections such as [Tables](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/tables-property/llms-full.txt), [Images](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/images-property/llms-full.txt) and [HeadersAndFooters](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/headersandfooters-property/llms-full.txt) give you the elements of the document.
- **Load and save documents** as DOCX, RTF, HTML, PDF and other formats, either through the built-in **Open** and **Save As** dialog boxes or directly from a file, a stream, a byte array or a string. See [Supported File Formats](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/overview/file-formats/llms-full.txt).
- **Review and protect documents.** Track changes, add comments, and make a document read-only except for the regions a user may edit.
- **Print** the document, with a print preview.

The ribbon, toolbars, rulers, status bar and sidebar that complete the editor are separate controls. [Ribbon, Toolbars, Rulers, and Status Bar](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/overview/components/ribbon-toolbars/llms-full.txt) and [Sidebar](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/overview/components/sidebar/llms-full.txt) describe them.

### Add It to a Form

After the setup is installed, the Visual Studio toolbox has a tab named **TX Text Control 34.0**. You draw the **TextControl** from that tab onto a form, and its smart tag adds a ribbon, rulers and a status bar and arranges them around the editor. [Create Your First Windows Forms Application](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/document-editor/first-application/llms-full.txt) walks through these steps, and [Visual Studio Designer Integration](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/integration/designer/llms-full.txt) describes the smart tag.

### How You Work With It

#### Choose How the Document Is Displayed

[ViewMode](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/viewmode-property/llms-full.txt) sets how the document appears: as pages like a printed document (`PageView`), formatted to the page width without pages (`Normal`), filling the width of the control (`FloatingText`) or like a text box of fixed size (`SimpleControl`). [Viewing, Zooming, and Navigation](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/viewing/llms-full.txt) compares the modes.

[PageSize](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/pagesize-property/llms-full.txt) and [PageMargins](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/pagemargins-property/llms-full.txt) are measured in the unit that [PageUnit](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/pageunit-property/llms-full.txt) selects, by default 1/100 inch. [ZoomFactor](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/zoomfactor-property/llms-full.txt) sets the zoom in percent.

#### Decide What Users May Change

[EditMode](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/editmode-property/llms-full.txt) controls editing: `Edit` allows everything, `ReadAndSelect` shows the text and lets users select it while [DocumentPermissions](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/documentpermissions-property/llms-full.txt) decides what else they may do, and `ReadOnly` only shows the text; see [Document Protection and Editable Regions](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/protection/llms-full.txt). [IsTrackChangesEnabled](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/istrackchangesenabled-property/llms-full.txt) turns on the marking of changes.

#### Work With the Content

- **The selection** is the center of most editing code. `Selection` refers to the part of the text that has the input focus, which is the main text, a header, a footer or a text frame. Setting its properties, such as `Bold` or `FontSize`, formats the selected text.
- **The collections** `Tables`, `Images`, [ApplicationFields](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/applicationfields-property/llms-full.txt), [Paragraphs](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/paragraphs-property/llms-full.txt) and [TrackedChanges](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/trackedchanges-property/llms-full.txt) also refer to the text part with the input focus. [Sections](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/sections-property/llms-full.txt) and [FormFields](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/formfields-property/llms-full.txt) hold elements of the whole document.
- **The input position** is where typed text appears. [InputPosition](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/inputposition-property/llms-full.txt) gets or sets it.

#### React to Changes

Events tell your code what happens in the editor. [Changed](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/changed-event/llms-full.txt) occurs when the contents change, for example to mark a document as modified. [InputPositionChanged](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/inputpositionchanged-event/llms-full.txt) occurs when the input position moves, for example to update your own toolbar. [DocumentLoaded](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/documentloaded-event/llms-full.txt) occurs after a document has been loaded.

### Example

[Load and Save Documents](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/document-editor/load-save/llms-full.txt) in Getting Started builds **New**, **Open**, **Save** and **Save As** commands around a `TextControl`: they use the built-in dialog boxes, track changes to the document with the `Changed` event and load and save files and byte arrays without a dialog box.

### Key Members

| Member | Purpose |
|---|---|
| [Load](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/load-method/llms-full.txt) | Loads a document and replaces the complete contents, or opens the Open dialog box. |
| [Save](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/save-method/llms-full.txt) | Saves the complete document, or opens the Save As dialog box. |
| [Append](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/append-method/llms-full.txt) | Adds a document to the end of the existing one. |
| [Selection](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/selection-property/llms-full.txt) | The current selection, used to insert text and to apply character and paragraph formatting. |
| [ViewMode](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/viewmode-property/llms-full.txt) | How the document is displayed. |
| [EditMode](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/editmode-property/llms-full.txt) | Whether the text can be edited, only selected or only read. |
| [Tables](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/tables-property/llms-full.txt), [Images](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/images-property/llms-full.txt), [HeadersAndFooters](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/headersandfooters-property/llms-full.txt) | The tables, images, headers and footers of the document. |
| [Comments](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/comments-property/llms-full.txt), [TrackedChanges](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/trackedchanges-property/llms-full.txt) | The comments and the tracked changes. |
| [Undo](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/undo-method/llms-full.txt), [Redo](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/redo-method/llms-full.txt) | Undo and redo the last action. [AllowUndo](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/allowundo-property/llms-full.txt) turns the undo history off, which saves time and memory when code builds a large document. |
| [Copy](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/copy-method/llms-full.txt), [Cut](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/cut-method/llms-full.txt), [Paste](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/paste-method/llms-full.txt) | Clipboard operations. |
| [Find](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/find-method/llms-full.txt), [Replace](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/replace-method/llms-full.txt) | Search the text in code, or open the built-in Find and Replace dialog boxes. |
| [Print](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/print-method/llms-full.txt), [PrintPreview](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/printpreview-method/llms-full.txt) | Print the document or show a preview. |
| [Changed](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/changed-event/llms-full.txt), [InputPositionChanged](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/inputpositionchanged-event/llms-full.txt) | Occur when the contents change and when the input position moves. |

The [TextControl](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/llms-full.txt) reference lists all members.

### Next Steps

- [Create Your First Windows Forms Application](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/document-editor/first-application/llms-full.txt): put a `TextControl` on a form and run it.
- [Ribbon, Toolbars, Rulers, and Status Bar](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/overview/components/ribbon-toolbars/llms-full.txt): the controls that complete the editor.
- [Document Editor](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/llms-full.txt): each editing feature of `TextControl` in detail.
- [ServerTextControl](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/overview/components/servertextcontrol/llms-full.txt): the same document engine without a user interface.

---

## Nearby

- **Previous:** [Components](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/overview/components/llms-full.txt)
- **Next:** [Ribbon, Toolbars, Rulers, and Status Bar](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/overview/components/ribbon-toolbars/llms-full.txt)
