# Selection Class

> The Selection class describes and handles the attributes of a text selection. Each of the properties of this class returns the property's default value if the selection does not contain a common value. In this case the IsCommonValueSelected method returns false.

- **Product:** TX Text Control .NET for Windows Forms
- **Section:** Reference
- **Kind:** Class
- **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 Class
- **2998 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/llms-full.txt

---

### Description

The Selection class describes and handles the attributes of a text selection. Each of the properties of this class returns the property's default value if the selection does not contain a common value. In this case the IsCommonValueSelected method returns false.

### Syntax

```csharp
public class Selection
```

```vbnet
Public Class Selection
```

### Examples

The following example shows how to select and format a piece of text.

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

TXTextControl.Selection mySel = new TXTextControl.Selection(3, 4);
mySel.Bold = true;
mySel.Italic = true;

textControl1.Selection = mySel;
```

```vbnet
TextControl1.Text = "TX Text Control"

Dim mySel as TXTextControl.Selection = New TXTextControl.Selection(3, 4)
mySel.Bold = True
mySel.Italic = True

TextControl1.Selection = mySel
```

The following example creates a reusable selection format and applies it to the current report heading.

```csharp
textControl.Text = "Quarterly results";
textControl.Select(0, textControl.Text.Length);
Selection selection = new() { Bold = true, FontSize = 280 };
textControl.Selection = selection;
```

```vbnet
textControl.Text = "Quarterly results"
textControl.Select(0, textControl.Text.Length)
Dim selection As New Selection() With { .Bold = True, .FontSize = 280 }
textControl.Selection = selection
```

---

## In This Section

- [Selection.Attribute Enumeration](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/attribute-enumeration/llms-full.txt): Determines a certain attribute. This enumeration is used with the IsCommonValueSelected method.
- [Selection.AutoBaseline Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/autobaseline-property/llms-full.txt): Gets or sets values specifying wheather the selected text is automatically sub- or superscripted. When using automatic sub- and superscript the font is scaled and moved above or below the baseline with values defined through the font itself. Automatic sub- and superscript can be combined with a user-defined baseline which can be set with the Baseline property.
- [Selection.Baseline Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/baseline-property/llms-full.txt): Gets or sets the baseline alignment, in twips, of the selected text. Positive values moves the baseline to superscript, negative values move the baseline to subscript.
- [Selection.Bold Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/bold-property/llms-full.txt): Gets or sets the bold attribute of the selected text.
- [Selection.Capitals Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/capitals-property/llms-full.txt): Gets or sets values specifying wheather the lowercase letters of the selected text are displayed with capital letters. Lowercase letters are displayed either with capital letters of the same size or with capital letters which have a smaller size. The smaller size is either the size of the lowercase 'x' (petite caps) or the size of the lowercase 'x' + 10% (small caps).
- [Selection.ChangeCapitalization Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/changecapitalization-method/llms-full.txt): Changes the capitalization of all selected characters depending on the settings parameter.
- [Selection.ChangeDirection Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/changedirection-method/llms-full.txt): Changes the writing direction of all selected paragraphs. When the direction of a paragraph is changed, this paragraph's alignment is toggled from left to right or from right to left. The alignment of centered and justified paragraphs is not changed. Left and right tabulators are also toggled.
- [Selection.CharacterScaling Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/characterscaling-property/llms-full.txt): Gets or sets a character scaling, in percent of the average character width, of the selected text.
- [Selection.CharacterSpacing Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/characterspacing-property/llms-full.txt): Gets or sets a character spacing value, in twips, of the selected text. This value is added to each character. When it is negative, character spacing is reduced, otherwise it is extended.
- [Selection Constructor](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/constructor/llms-full.txt): Creates a new instance of the Selection class.
- [Selection.Culture Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/culture-property/llms-full.txt): Gets or sets the culture of the selected text.
- [Selection.DecreaseIndent Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/decreaseindent-method/llms-full.txt): Decreases the left indent of all paragraphs contained in the current text selection. If no text is selected, this method decreases the left indent at the text input position. Left indent positions are defined through the paragraphs' tab positions and the indents of the paragraphs in front and behind the paragraph with the text input position.
- [Selection.DialogResult Enumeration](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/dialogresult-enumeration/llms-full.txt): Specifies identifiers to indicate the return value of a dialog box.
- [Selection.FontName Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/fontname-property/llms-full.txt): Gets or sets the font of the selected text.
- [Selection.FontSize Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/fontsize-property/llms-full.txt): Gets or sets the font's size, in twips, of the selected text.
- [Selection.ForeColor Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/forecolor-property/llms-full.txt): Returns or sets the color used to display the selected text.
- [Selection.FormattingStyle Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/formattingstyle-property/llms-full.txt): Gets or sets the formatting style of the selected text.
- [Selection.GrowFont Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/growfont-method/llms-full.txt): Increases the font size of each font contained in the current text selection. If no text is selected, this method increases the font size at the text input position. The font sizes used with this method are the same as shown through the ButtonBar or the built-in font dialog.
- [Selection.IncreaseIndent Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/increaseindent-method/llms-full.txt): Increases the left indent of all paragraphs contained in the current text selection. If no text is selected, this method increases the left indent at the text input position. left indent positions are defined through the paragraphs' tab positions and the indents of the paragraphs in front and behind the paragraph with the text input position.
- [Selection.IsCommonValueSelected Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/iscommonvalueselected-method/llms-full.txt): Informs about whether a certain attribute has the same value for the complete selection.
- [Selection.Italic Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/italic-property/llms-full.txt): Gets or sets the italic attribute of the selected text.
- [Selection.Length Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/length-property/llms-full.txt): 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.
- [Selection.ListFormat Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/listformat-property/llms-full.txt): Gets or sets a bulleted or numbered list and/or its formatting attributes for the selected text. The property's value is an object of the type ListFormat.
- [Selection.Load Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/load-method/llms-full.txt): Exchanges the currently selected text with text in a certain format.
- [Selection.ParagraphFormat Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/paragraphformat-property/llms-full.txt): Gets or sets the formatting attributes of the selected paragraphs. The property's value is an object of the type ParagraphFormat.
- [Selection.RemoveFormatting Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/removeformatting-method/llms-full.txt): Resets all character based formatting attributes of the selected text to its default values. If nothing or more than one paragraph is selected, all paragraph based formatting attributes are also reset.
- [Selection.RemoveInlineStyles Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/removeinlinestyles-method/llms-full.txt): Removes all character based styles of the selected text so that all attributes are reset to the attributes of the paragraph style.
- [Selection.Save Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/save-method/llms-full.txt): Saves the selected text of a document with the specified format.
- [Selection.SectionFormat Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/sectionformat-property/llms-full.txt): Gets or sets page settings such as margins, size and orientation for the selected text. The property's value is an object of the type SectionFormat.
- [Selection.ShrinkFont Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/shrinkfont-method/llms-full.txt): Decreases the font size of each font contained in the current text selection. If no text is selected, this method decreases the font size at the text input position. The font sizes used with this method are the same as shown through the ButtonBar or the built-in font dialog.
- [Selection.Start Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/start-property/llms-full.txt): Gets or sets the starting point of selected text. The first possible position is 0. If the starting point of a selection is set to a new value, the selection's current length remains the same. To set a new starting point and a length simultaneously, use either the TextControl.Select method or create a new Selection object. To select parts of a table, use the Table.Select, TableRow.Select, TableColumn.Select and TableCell.Select methods.
- [Selection.Strikeout Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/strikeout-property/llms-full.txt): Gets or sets the strikeout attribute of the selected text.
- [Selection.Text Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/text-property/llms-full.txt): Gets or sets a string containing the currently selected text.
- [Selection.TextBackColor Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/textbackcolor-property/llms-full.txt): Gets or sets the background color for selected text.
- [Selection.Underline Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/underline-property/llms-full.txt): Gets or sets underlining styles for the selected text.

---

## Nearby

- **Previous:** [SectionFormat.RestartPageNumbering Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/sectionformat/restartpagenumbering-property/llms-full.txt)
- **Next:** [Selection.Attribute Enumeration](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selection/attribute-enumeration/llms-full.txt)
