TX Text Control Blog

Manipulating the Selection object

Blogged by Björn Meyer on May 26, 2008 and tagged with .net, sample.

To change the formatting of a specific part of a document, you need to select it using the Selection class of TX Text Control .NET for Windows Forms.

At first sight, some programmers do not see that the Selection object can be created and manipulated independently from the current text. You can create a new Selection object, adjust the formatting and set the text before applying this object to the current selection.

This below code shows this approach by using the currently selected text in TX Text Control.

TXTextControl.Selection mySel = new TXTextControl.Selection(textControl1.Selection.Start, textControl1.Selection.Length); mySel.Bold = true; mySel.Italic = true; mySel.ParagraphFormat.Alignment = TXTextControl.HorizontalAlignment.Right; mySel.Text = "New Text"; textControl1.Selection = mySel;
 
 
 

Products

Support

Downloads

Corporate

Buy Now