[]
Tab stops are used in Word documents to enable text alignment by pressing the Tab key from the keyboard. There are generally five types of tab stops, namely, left, right, center, decimal, and bar tab.
GcWord allows you to specify tab stop properties for a paragraph using the TabStop class which can be accessed using TabStops property of the ParagraphFormat class. It supports all the five types of tab stops which can be set using Alignment property of the TabStop class. This property takes value from the TabStopAlignment enumeration.
To get the tab stops:
Access a paragraph from the paragraph collection using Paragraphs property of the RangeBase class.
Access the paragraph formatting properties using Format property of the Paragraph class.
Get the tab stop properties applied to the paragraph using TabStops property of the ParagraphFormat class.
Get tab stop property. For example, get the position of the tab stop in points using Position property of the TabStop class.
Display the indent value on the console.
//Get tab stops
Console.WriteLine("Tab Stop: "+
doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.TabStops[0].Position);
To set the tab stops:
Access a paragraph from the paragraph collection using Paragraphs property of the RangeBase class.
Access the paragraph formatting properties using Format property of the Paragraph class.
Get the tab stop properties applied to the paragraph using TabStops property of the ParagraphFormat class.
Add or replace the tab stop in the collection using Add method of the TabStopCollection class.
//Set tab stops
doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.TabStops.Add(20, TabStopAlignment.Bar);
For more information on how to implement tab stops using GcWord, see GcWord sample browser.