# InputPosition, TextChars and Selection: Various Ways to Manipulate Text and the Input Position

> TX Text Control provides many ways to set the input position, to manipulate text, and to retrieve text at the current input position. This article gives an overview of various API members and their typical applications.

- **Author:** Bjoern Meyer
- **Published:** 2023-01-09
- **Modified:** 2025-11-16
- **Description:** TX Text Control provides many ways to set the input position, to manipulate text, and to retrieve text at the current input position. This article gives an overview of various API members and their typical applications.
- **3 min read** (579 words)
- **Tags:**
  - ASP.NET
  - Windows Forms
  - Input Position
- **Web URL:** https://www.textcontrol.com/blog/2023/01/09/inputposition-textchars-and-selection-various-ways-to-manipulate-text-and-the-input-position/
- **LLMs URL:** https://www.textcontrol.com/blog/2023/01/09/inputposition-textchars-and-selection-various-ways-to-manipulate-text-and-the-input-position/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2023/01/09/inputposition-textchars-and-selection-various-ways-to-manipulate-text-and-the-input-position/llms-full.txt

---

Text can be manipulated in many ways using the TX Text Control API. Depending on the current task, various classes can be used to set the input position, to retrieve the text or to set the text at the current input position.

### The Basics: The Input Position

The following two properties can be used to manipulate the input position:

- Selection class
- InputPosition class

Both classes can be use to set the input position to a specific character index which is 0-based.

![TX Text Control Input Position](https://s1-www.textcontrol.com/assets/dist/blog/2023/01/09/b/assets/inputposition.svg "TX Text Control Input Position")

#### Selection Class

The following code uses the Selection class to set the input position to the index location 3 which is the beginning of character location 4.

```
textControl1.Selection.Start = 3;
```

The *Selection* class can be now used to select a range of text in order to replace it with new text.

```
textControl1.Selection.Start = 3;
textControl1.Selection.Length = 4;
textControl1.Selection.Text = "New Text";
```

![Selecting Text](https://s1-www.textcontrol.com/assets/dist/blog/2023/01/09/b/assets/step1.webp "Selecting Text")

Although the above code works, the *Selection* class should be used in a different way. The Selection property accepts a complete *Selection* object. The object can be prepared and then applied to the text as shown in the code snippet below.

```
textControl1.Text = "TX Text Control";

TXTextControl.Selection selection = new TXTextControl.Selection(3, 4) {
 Text = "New Text"
};

textControl1.Selection = selection;
```

#### InputPosition Class

The InputPosition constructor offers other possibilities to set the input position. This class can be used to set the input position in case the X and Y coordinates are known or a specific page, column and row number is used. The following implementations of the constructor are available:

```
public InputPosition(int page, int line, int column);
public InputPosition(int textPosition);
public InputPosition(int textPosition, TextFieldPosition textFieldPosition);
public InputPosition(Point location);
```

To set the input position to index 3 similar to the above sample using the *Selection* property, the following code is required.

```
textControl1.InputPosition = new TXTextControl.InputPosition(3);
```

#### Retrieving Text

In order to retrieve text from a specific range of text, the *Selection* class must be used. The following code shows how to retrieve the string "Text" from the above sample.

```
textControl1.Text = "TX Text Control";
 TXTextControl.Selection selection = new TXTextControl.Selection(3, 4);
 textControl1.Selection = selection;
 var selectedText = selection.Text;
```

To get the formatted text in any supported format, the Selection.Save method can be utilized. The following code shows how retrieve the word "Text" in HTML format.

```
string htmlString;

textControl1.Text = "TX Text Control";
TXTextControl.Selection selection = new TXTextControl.Selection(3, 4);
textControl1.Selection = selection;
selection.Save(out htmlString, TXTextControl.StringStreamType.HTMLFormat);
```

The variable *htmlString* contains the word "Text" in HTML format.

```
<?xml version="1.0" ?>
<html xmlns="http://www.w3.org/1999/xhtml">
   <head>
      <meta content="TX31_HTM 31.0.1101.500" name="GENERATOR" />
      <title></title>
   </head>
   <body style="font-family:'Arial';font-size:12pt;text-align:left;">
      <p lang="en-US" style="text-indent:0pt;margin-top:0pt;margin-bottom:0pt;font-size:10pt;">Text</p>
   </body>
</html>
```

#### Retrieving Text without Selecting Text

Using the above methods the text must be selected to retrieve the text. The TextChar class can be used to retrieve a character at a specific location without setting the input position to that location. The following code returns the character "T" at index 4.

```
var charAtInputPos = textControl1.TextChars[4].Char;
```

The Line class can be used to retrieve text from a specific line. The following code returns the complete text of the first line.

```
var lineText = textControl1.Lines[1].Text;
```

The third option to retrieve text without selecting text is the usage of the Paragraph class that represents a complete paragraph including text and formatting. The following code returns the plain text of the complete paragraph based on input position 3.

```
var parText = textControl1.Paragraphs.GetItem(3).Text;
```

---

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

- [TX Text Control 34.0 SP4 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2026/05/20/tx-text-control-34-0-sp4-is-now-available/llms.txt)
- [TXTextControl.Markdown.Core 34.1.0-beta: Work with Full Documents, Selection, and SubTextParts](https://www.textcontrol.com/blog/2026/04/14/txtextcontrol-markdown-core-34-1-0-beta-work-with-full-documents-selection-and-subtextparts/llms.txt)
- [TX Spell .NET 11.0 SP1 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2026/04/08/tx-spell-net-11-0-sp1-is-now-available/llms.txt)
- [TX Text Control 34.0 SP2 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2026/02/18/tx-text-control-34-0-sp2-is-now-available/llms.txt)
- [TX Text Control 34.0 SP1 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2025/12/03/tx-text-control-34-0-sp1-is-now-available/llms.txt)
- [Introducing TX Text Control 34.0: Your Next Leap in Document Processing](https://www.textcontrol.com/blog/2025/11/10/introducing-tx-text-control-34-0-your-next-leap-in-document-processing/llms.txt)
- [Sneak Peek: TX Text Control 34.0 Coming November 2025](https://www.textcontrol.com/blog/2025/10/02/sneak-peek-tx-text-control-34-0-coming-november-2025/llms.txt)
- [TX Text Control 33.0 SP3 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2025/08/14/tx-text-control-33-0-sp3-is-now-available/llms.txt)
- [TX Text Control 33.0 SP2 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2025/06/18/tx-text-control-33-0-sp2-is-now-available/llms.txt)
- [Document Lifecycle Optimization: Leveraging TX Text Control's Internal Format](https://www.textcontrol.com/blog/2025/05/16/document-lifecycle-optimization-leveraging-tx-text-controls-internal-format/llms.txt)
- [Expert Implementation Services for Legacy System Modernization](https://www.textcontrol.com/blog/2025/05/07/expert-implementation-services-for-legacy-system-modernization/llms.txt)
- [Service Pack Releases: What's New in TX Text Control 33.0 SP1 and 32.0 SP5](https://www.textcontrol.com/blog/2025/05/07/service-pack-releases-whats-new-in-tx-text-control-33-0-sp1-and-32-0-sp5/llms.txt)
- [Top 5 Real-World Applications for TX Text Control Document Processing Libraries](https://www.textcontrol.com/blog/2025/04/01/top-5-real-world-applications-for-tx-text-control-document-processing-libraries/llms.txt)
- [DWX Developer Week Moves to Mannheim - And Text Control Is on Board!](https://www.textcontrol.com/blog/2025/03/19/dwx-developer-week-moves-to-mannheim-and-tx-text-control-is-on-board/llms.txt)
- [The Wait is Over: TX Text Control for Linux is Officially Here](https://www.textcontrol.com/blog/2025/03/12/the-wait-is-over-tx-text-control-for-linux-is-officially-here/llms.txt)
- [Splitting Tables at Bookmark Positions and Cloning Table Headers](https://www.textcontrol.com/blog/2025/02/13/splitting-tables-at-bookmark-positions-and-cloning-table-headers/llms.txt)
- [Full .NET 9 Support in Text Control .NET Components for ASP.NET Core, Windows Forms, and WPF](https://www.textcontrol.com/blog/2024/11/11/full-net-9-support-in-text-control-net-components-for-asp-net-core-windows-forms-and-wpf/llms.txt)
- [Toggle Field Codes in TX Text Control](https://www.textcontrol.com/blog/2024/11/07/toggle-field-codes-in-tx-text-control/llms.txt)
- [Loading and Processing Excel XLSX Spreadsheet Tables into TX Text Control using .NET C#](https://www.textcontrol.com/blog/2024/10/16/loading-and-processing-excel-spreadsheet-tables-into-tx-text-control-using-net-csharp/llms.txt)
- [TX Text Control 32.0 Service Pack 4 Released](https://www.textcontrol.com/blog/2024/09/02/tx-text-control-32-0-service-pack-4-released/llms.txt)
- [Print MS Word DOCX Documents in .NET using C# Without Interop](https://www.textcontrol.com/blog/2024/06/28/print-ms-word-docx-documents-in-net-using-c-sharp-without-interop/llms.txt)
- [Text to Table and Table to Text in TX Text Control and C#](https://www.textcontrol.com/blog/2024/06/26/text-to-table-and-table-to-text-in-tx-text-control-and-csharp/llms.txt)
- [Document Templates Tip: Say No to Forced Page Breaks](https://www.textcontrol.com/blog/2024/05/28/document-templates-tip-say-no-to-forced-page-breaks/llms.txt)
- [Selecting and Formatting TableCells in TX Text Control](https://www.textcontrol.com/blog/2024/05/20/selecting-and-formatting-tablecells-in-tx-text-control/llms.txt)
- [Various Ways of Inserting Images into TX Text Control](https://www.textcontrol.com/blog/2024/05/03/various-ways-of-inserting-images-into-tx-text-control/llms.txt)
