Selection Class
- Namespace
TXTextControl
- Package
TXTextControl.from the private NuGet feed or Text Control Offline PackagesTextControl. Core. SDK
- Assembly
TXTextControl.Core. dll
- Install
dotnet add package TXTextControl..NET 8 and later. For .NET Framework, referenceTextControl. Core. SDK TXTextControl.from the setup.dll
- Also in
TXTextControl.asTextControl. ASP. SDK TXTextControl.dll
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
public class SelectionPublic Class SelectionExamples
The following example shows how to select and format a piece of text.
textControl1.Text = "TX Text Control";
TXTextControl.Selection mySel = new TXTextControl.Selection(3, 4);
mySel.Bold = true;
mySel.Italic = true;
textControl1.Selection = mySel;TextControl1.Text = "TX Text Control"
Dim mySel as TXTextControl.Selection = New TXTextControl.Selection(3, 4)
mySel.Bold = True
mySel.Italic = True
TextControl1.Selection = mySelThe following example creates a reusable selection format and applies it to the current report heading.
textControl.Text = "Quarterly results";
textControl.Select(0, textControl.Text.Length);
Selection selection = new() { Bold = true, FontSize = 280 };
textControl.Selection = selection;textControl.Text = "Quarterly results"
textControl.Select(0, textControl.Text.Length)
Dim selection As New Selection() With { .Bold = True, .FontSize = 280 }
textControl.Selection = selectionMembers
Constructors
| Constructor | Description |
|---|---|
| Selection | Creates a new instance of the Selection class. |
Properties
| Property | Description |
|---|---|
| AutoBaseline | 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. |
| Baseline | 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. |
| Bold | Gets or sets the bold attribute of the selected text. |
| Capitals | 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). |
| CharacterScaling | Gets or sets a character scaling, in percent of the average character width, of the selected text. |
| CharacterSpacing | 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. |
| Culture | Gets or sets the culture of the selected text. |
| FontName | Gets or sets the font of the selected text. |
| FontSize | Gets or sets the font's size, in twips, of the selected text. |
| ForeColor | Returns or sets the color used to display the selected text. |
| FormattingStyle | Gets or sets the formatting style of the selected text. |
| Italic | Gets or sets the italic attribute of the selected text. |
| Length | 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. |
| ListFormat | 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. |
| ParagraphFormat | Gets or sets the formatting attributes of the selected paragraphs. The property's value is an object of the type ParagraphFormat. |
| SectionFormat | 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. |
| Start | 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. |
| Strikeout | Gets or sets the strikeout attribute of the selected text. |
| Text | Gets or sets a string containing the currently selected text. |
| TextBackColor | Gets or sets the background color for selected text. |
| Underline | Gets or sets underlining styles for the selected text. |
Methods
| Method | Description |
|---|---|
| ChangeCapitalization | Changes the capitalization of all selected characters depending on the settings parameter. |
| ChangeDirection | 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. |
| DecreaseIndent | 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. |
| GrowFont | 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. |
| IncreaseIndent | 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. |
| IsCommonValueSelected | Informs about whether a certain attribute has the same value for the complete selection. |
| Load | Exchanges the currently selected text with text in a certain format. |
| RemoveFormatting | 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. |
| RemoveInlineStyles | Removes all character based styles of the selected text so that all attributes are reset to the attributes of the paragraph style. |
| Save | Saves the selected text of a document with the specified format. |
| ShrinkFont | 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. |
Enumerations
| Enumeration | Description |
|---|---|
| Attribute | Determines a certain attribute. This enumeration is used with the IsCommonValueSelected method. |
| DialogResult | Specifies identifiers to indicate the return value of a dialog box. |