Products Technologies Demo Docs Blog Support Company

Word Processing Basics: Using Style Sheets

The usage of style sheets is a elegant, abstract way to separate the formatting from the associated text. You might use this feature in MS Word without understanding the word processing background of it. Every time, you are using a template to write a letter or fax in MS Word, styles are used to control the text formatting. Using styles, the formatting can be stored, modified and applied separately from the text. In HTML, this style information is saved in the CSS format in the HTML header…

Word Processing Basics: Using Style Sheets
Styles in TX Text Control

The usage of style sheets is a elegant, abstract way to separate the formatting from the associated text. You might use this feature in MS Word without understanding the word processing background of it. Every time, you are using a template to write a letter or fax in MS Word, styles are used to control the text formatting.

Using styles, the formatting can be stored, modified and applied separately from the text. In HTML, this style information is saved in the CSS format in the HTML header or in a separate file. In other formats such as DOCX or the internal TX Text Control format, styles are stored in separate tables in the document format itself.

Make changes to the formatting once and let the styles do the work for you. Consider the following scenario: You want to change each and every heading in your 100 page document. Instead of applying the new style to every paragraph, you simply change the associated style in order to apply the changes to the document.

Changing a style can be done using the ready-to-use dialog box and using the powerful API of TX Text Control. TX Text Control differentiates between ParagraphStyles and InlineStyles - both derivatives of the base class FormattingStyle.

The following code shows how to create and apply a new style to the paragraph at the current input position:

ParagraphStyle psHeading1 = new ParagraphStyle("Heading 1");
psHeading1.Bold = true;
psHeading1.FontSize = 1000;
psHeading1.Underline = FontUnderlineStyle.Doubled;

textControl1.ParagraphStyles.Add(psHeading1);

textControl1.Selection.FormattingStyle = psHeading1.Name;

In case that the style already exists in the document, you can use the code snippet below to modify and apply an existing style:

ParagraphStyle psStyle = textControl1.ParagraphStyles.GetItem("Heading 1");
psStyle.Italic = true;

psStyle.Apply();

In this case, the formatting of all paragraphs with this specific style is changed at once.

Start today and download a fully featured, 30 day trial version

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

Related Posts

Windows FormsGetting StartedTutorial

Windows Forms Tutorial: Create Your First Windows Forms C# Application

This tutorial shows how to create your first Windows Forms application with C# using TX Text Control .NET for Windows Forms in Visual Studio 2022.


ASP.NETASP.NET CoreMailMerge

How to Mail Merge MS Word DOCX Documents in ASP.NET Core C#

Mail merge is the process of merging data, such as Json or IEnumerable objects, into a template document, such as a DOC or DOCX file. This tutorial is a walkthrough of the steps necessary to…


AngularDocument EditorNode.js

Creating an Angular Document Editor Application with a Node.js WebSocket Server

This tutorial shows how to create an Angular application that uses the Document Editor with a Node.js WebSocket server.


ASP.NETASP.NET CoreMailMerge

Adding SVG Watermarks to Documents

This article shows how to add SVG images to document section headers that repeat automatically on each page. This watermark will be inserted vertically and horizontally centered on each section page.


ASP.NETASP.NET CoreMailMerge

Using MailMerge in ASP.NET Core 6 Web Applications

This article shows how to use the TX Text Control ASP.NET MailMerge class to merge templates with JSON data within a .NET 6 application in Visual Studio 2022.