This message contains graphics. If you do not see the graphics: Graphic Version.
 
Styles Tricks in TX Text Control .NET for Windows Forms

In this newsletter, we are going to show you some interesting tricks using styles in TX Text Control .NET for Windows Forms

Thanks to the new class oriented design of TX Text Control .NET for Windows Forms, manipulating the internal styles of TX Text Control has become very easy. The shipped button bar includes a combo box to select and apply every style to a paragraph. Many customers, however, would like to be able to offer their end-users a style selection box that is not part of the button bar.

In this newsletter, we are going to show you how to fill in a combo box with the styles available in TX Text Control. We use a dialog form to create a "style selector" where the user can choose a style and apply it to specific paragraphs.

Using the ParagraphStyleCollection and a simple Visual Basic "For Each" statement, it is very simple to fill a list box with the styles.

Dim style As TXTextControl.FormattingStyle styleDialog.ListBox1.Items.Clear() For Each style In TextControl1.ParagraphStyles styleDialog.ListBox1.Items.Add(style.Name) Next

Every available style is displayed in the style selector form and the user can choose one of the styles. In this case, the whole paragraph is selected, so that the selected style can be applied to the complete paragraph. This is done by searching for carriage returns in the text to get to the start and to the end positions of the current paragraph.

paragraphStart = tx.Find(Chr(10), curPos, 17) paragraphEnd = tx.Find(Chr(10), curPos, 16)

Additionally, the user should be able to see the font settings of the selected style in a preview window. For this reason, we use a second TX Text Control and copy the selected paragraph into the new TX Text Control. The font attributes can be simply applied using the selected style object:

TextControl1.Selection.FontName = tx.ParagraphStyles.GetItem(ListBox1.SelectedItem).FontName

Finally, if the user presses the button "Apply", the selected style will be applied to the specified paragraph.

tx.Selection.FormattingStyle = ListBox1.SelectedItem

Best regards

The Newsletter Team

Text Control GmbH respects your online time and privacy. We only send this newsletter to TX Text Control customers and people who have signed up to receive it. However, if you would prefer not to receive future issues of the newsletter, you may unsubscribe at any time. If you received this newsletter forwarded from a colleague or friend, you may wish to subscribe directly.

Sent to: N/A.

Imprint | Unsubscribe | Subscribe

© 2004 Text Control GmbH. All Rights Reserved.