TabStop Class

Represents a single custom tab stop. The TabStop object is a member of the TabStopCollection collection.
Inheritance Hierarchy
SystemObject
  Aspose.WordsTabStop

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
[SerializableAttribute]
public sealed class TabStop

The TabStop type exposes the following members.

Constructors
  NameDescription
Public methodCode exampleTabStop(Double)
Initializes a new instance of this class.
Public methodCode exampleTabStop(Double, TabAlignment, TabLeader)
Initializes a new instance of this class.
Properties
  NameDescription
Public propertyCode exampleAlignment
Gets or sets the alignment of text at this tab stop.
Public propertyCode exampleIsClear
Returns true if this tab stop clears any existing tab stops in this position.
Public propertyCode exampleLeader
Gets or sets the type of the leader line displayed under the tab character.
Public propertyCode examplePosition
Gets the position of the tab stop in points.
Methods
  NameDescription
Public methodEquals(Object) (Inherited from Object.)
Public methodCode exampleEquals(TabStop)
Compares with the specified TabStop.
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Public methodToString (Inherited from Object.)
Remarks

Normally, a tab stop specifies a position where a tab stop exists. But because tab stops can be inherited from parent styles, it might be needed for the child object to define explicitly that there is no tab stop at a given position. To clear an inherited tab stop at a given position, create a TabStop object and set Alignment to TabAlignment.Clear.

For more information see TabStopCollection.

Examples
Shows how to modify the position of the right tab stop in TOC related paragraphs.
Document doc = new Document(MyDir + "Table of contents.docx");

// Iterate through all paragraphs in the document
foreach (Paragraph para in doc.GetChildNodes(NodeType.Paragraph, true).OfType<Paragraph>())
{
    // Check if this paragraph is formatted using the TOC result based styles. This is any style between TOC and TOC9
    if (para.ParagraphFormat.Style.StyleIdentifier >= StyleIdentifier.Toc1 &&
        para.ParagraphFormat.Style.StyleIdentifier <= StyleIdentifier.Toc9)
    {
        // Get the first tab used in this paragraph, this should be the tab used to align the page numbers
        TabStop tab = para.ParagraphFormat.TabStops[0];
        // Remove the old tab from the collection
        para.ParagraphFormat.TabStops.RemoveByPosition(tab.Position);
        // Insert a new tab using the same properties but at a modified position
        // We could also change the separators used (dots) by passing a different Leader type
        para.ParagraphFormat.TabStops.Add(tab.Position - 50, tab.Alignment, tab.Leader);
    }
}

doc.Save(ArtifactsDir + "Styles.ChangeTocsTabStops.docx");
See Also