# Selection.Text Property

> Gets or sets a string containing the currently selected text.

- **Product:** TX Text Control .NET Server
- **Section:** Reference
- **Kind:** Property
- **Namespace:** `TXTextControl`
- **Package:** `TXTextControl.TextControl.Core.SDK` (assembly `TXTextControl.Core.dll`, from the private NuGet feed or Text Control Offline Packages)
- **Package:** `TXTextControl.TextControl.ASP.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 Server > Reference > TXTextControl > Selection.Text Property
- **577 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/selection/text-property/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/selection/text-property/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/selection/text-property/llms-full.txt

---

### Description

Gets or sets a string containing the currently selected text.

### Syntax

```csharp
public string Text { get; set; }
```

```vbnet
Public Property Text As String
```

### Examples

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

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

selection.Text = "Quarterly results";
if (!string.IsNullOrWhiteSpace(selection.Text))
{
    Console.WriteLine($"Text: {selection.Text}");
}
```

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

selection.Text = "Quarterly results"
If Not String.IsNullOrWhiteSpace(selection.Text) Then
    Console.WriteLine($"Text: {selection.Text}")
End If
```

### Limitations

Runtime only.

---

## Nearby

- **Previous:** [Selection.Strikeout Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/selection/strikeout-property/llms-full.txt)
- **Next:** [Selection.TextBackColor Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/selection/textbackcolor-property/llms-full.txt)
