Documents for Word .NET Edition
Features / Paragraph / Tab Stops
In This Topic
    Tab Stops
    In This Topic

    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.

    Get Tab Stops

    To get the tab stops:

    1. Access a paragraph from the paragraph collection using Paragraphs property of the RangeBase class.
    2. Access the paragraph formatting properties using Format property of the Paragraph class.
    3. Get the tab stop properties applied to the paragraph using TabStops property of the ParagraphFormat class.
    4. Get tab stop property. For example, get the position of the tab stop in points using Position property of the TabStop class.
    5. Display the indent value on the console.
      C#
      Copy Code
      //Get tab stops
      Console.WriteLine("Tab Stop: "+ 
          doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.TabStops[0].Position);
    Back to Top

    Set Tab Stops

    To set the tab stops:

    1. Access a paragraph from the paragraph collection using Paragraphs property of the RangeBase class.
    2. Access the paragraph formatting properties using Format property of the Paragraph class.
    3. Get the tab stop properties applied to the paragraph using TabStops property of the ParagraphFormat class.
    4. Add or replace the tab stop in the collection using Add method of the TabStopCollection class.
      C#
      Copy Code
      //Set tab stops
      doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.TabStops.Add(20, TabStopAlignment.Bar);
    Back to Top

    For more information on how to implement tab stops using GcWord, see GcWord sample browser.