TX Text Control Blog

Copy all styles from one TextControl into another

Blogged by Björn Meyer on May 31, 2007 and tagged with sample, .net.

Sometimes, it is required to copy all styles of the InlineStyles or ParagraphStyles collection to another instance of TextControl without cloning the whole text.

In this case, you can simply use a foreach loop to iterate through all styles. In this loop, you need to create a new instance of the style object that can be added to the style collection of the second TX Text Control.

The following code copies all InlineStyles from textControl1 to the second instance textControl2:

foreach (TXTextControl.InlineStyle curStyle in textControl1.InlineStyles) { TXTextControl.InlineStyle newStyle = new TXTextControl.InlineStyle(curStyle); textControl2.InlineStyles.Add(newStyle); }
 
 
 

Products

Support

Downloads

Corporate

Buy Now