# Selection.Length Property

> Returns or sets the number of characters selected. If this property is zero, no text is selected and the Start property determines the current text input position. To select parts of a table, the Table.Select, TableRow.Select, TableColumn.Select and TableCell.Select methods must be used.

- **Product:** TX Text Control .NET for Windows Forms
- **Section:** Reference
- **Kind:** Property
- **Namespace:** `TXTextControl`
- **Package:** `TXTextControl.TextControl.WinForms.SDK` (assembly `TXTextControl.dll`, from the private NuGet feed or Text Control Offline Packages)
- **.NET Framework:** reference `TXTextControl.dll` from the setup
- **Path:** TX Text Control .NET for Windows Forms > Reference > TXTextControl > Selection.Length Property
- **626 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/length-property/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/length-property/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/length-property/llms-full.txt

---

### Description

Returns or sets the number of characters selected. If this property is zero, no text is selected and the [Start](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/start-property/llms-full.txt) property determines the current text input position. To select parts of a table, the [Table.Select](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/table/select-method/llms-full.txt), [TableRow.Select](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/tablerow/select-method/llms-full.txt), [TableColumn.Select](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/tablecolumn/select-method/llms-full.txt) and [TableCell.Select](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/tablecell/select-method/llms-full.txt) methods must be used.

### Syntax

```csharp
public int Length { get; set; }
```

```vbnet
Public Property Length As Integer
```

### Examples

The following example formats the heading of a short document by using `Selection.Length`.

```csharp
textControl.Text = "Quarterly results\nRevenue increased by 12%.";
textControl.Select(0, 17);
Selection selection = textControl.Selection;

selection.Length = 1;
Console.WriteLine($"Length used by Selection: {selection.Length}");
```

```vbnet
textControl.Text = "Quarterly results" & vbCrLf & "Revenue increased by 12%."
textControl.Select(0, 17)
Dim selection As Selection = textControl.Selection

selection.Length = 1
Console.WriteLine($"Length used by Selection: {selection.Length}")
```

### Limitations

Runtime only.

### Remarks

If the [Start](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/start-property/llms-full.txt) property is set to zero and the Length property is set to `int.MaxValue` all the text is selected.

---

## Nearby

- **Previous:** [Selection.Italic Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/italic-property/llms-full.txt)
- **Next:** [Selection.ListFormat Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/listformat-property/llms-full.txt)
