Click or drag to resize
TabStopCollection Class
Represents a set of TabStops.
Inheritance Hierarchy
SystemObject
  GemBox.DocumentTabStopCollection

Namespace:  GemBox.Document
Assembly:  GemBox.Document (in GemBox.Document.dll) Version: 25.3.30.1255
Syntax
public sealed class TabStopCollection : IList<TabStop>, 
	ICollection<TabStop>, IEnumerable<TabStop>, IEnumerable

The TabStopCollection type exposes the following members.

Properties
  NameDescription
Public propertyCount
Gets the number of TabStops contained in the TabStopCollection.
Public propertyItem
Gets or sets the TabStop at the specified index.
Top
Methods
  NameDescription
Public methodAdd
Public methodClear
Public methodContains
Public methodCopyTo
Public methodEquals
Determines whether the specified Object is equal to this TabStopCollection instance.
(Overrides ObjectEquals(Object).)
Public methodGetEnumerator
Returns an enumerator that iterates through the collection.
Public methodGetHashCode
Returns a hash code for this TabStopCollection instance.
(Overrides ObjectGetHashCode.)
Public methodIndexOf
Public methodInsert
Public methodRemove
Public methodRemoveAt
Top
Operators
  NameDescription
Public operatorStatic memberEquality
Determines whether first and second TabStopCollections are equal.
Public operatorStatic memberInequality
Determines whether first and second TabStopCollections are not equal.
Top
Explicit Interface Implementations
  NameDescription
Explicit interface implementationPrivate methodIEnumerableGetEnumerator
Returns an enumerator that iterates through a collection.
Top
Remarks

Creating customized tabs in a document is accomplished with TabStop structure that enables you to define tab position, tab leader character and surrounding text alignment.

TabStops should be inserted into ParagraphFormat.Tabs collection to be used in a Paragraph.

Tabs are inserted into a document content with SpecialCharacter elements that have SpecialCharacter.CharacterType property equal to Tab.

Values Bar and List are currently not supported in PDF, XPS and image file formats.

Examples

Following example shows how to define customized tab stops and insert the tabs in document content.

// Create a new empty document.
var doc = new DocumentModel();

// Define document content and paragraph formatting in one code statement.
doc.Sections.Add(
    new Section(doc,
        new Paragraph(doc,
            // Add two lines of text: first with text and tabs, second with only tabs - so tab stop position, tab stop alignment and tab stop leader values can be observed more closely.
            new Run(doc, "First"),
            new SpecialCharacter(doc, SpecialCharacterType.Tab),
            new Run(doc, "Second"),
            new SpecialCharacter(doc, SpecialCharacterType.Tab),
            new Run(doc, "Third"),
            new SpecialCharacter(doc, SpecialCharacterType.Tab),
            new Run(doc, "Fourth"),
            new SpecialCharacter(doc, SpecialCharacterType.LineBreak),
            new SpecialCharacter(doc, SpecialCharacterType.Tab),
            new SpecialCharacter(doc, SpecialCharacterType.Tab),
            new SpecialCharacter(doc, SpecialCharacterType.Tab))
        {
            ParagraphFormat = new ParagraphFormat()
            {
                Tabs =
                {
                    // Define three tab stops, with different alignments and leader characters, each ending 1000 points after the previous one.
                    new TabStop(100, TabStopAlignment.Left, TabStopLeader.Dot),
                    new TabStop(200, TabStopAlignment.Center, TabStopLeader.Hyphen),
                    new TabStop(300, TabStopAlignment.Right, TabStopLeader.Underscore)
                }
            }
        }));

// Document will be saved on the Desktop.
var path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "TabStops.docx");

// Save the document.
doc.Save(path);

// Open the document in Microsoft Word.
System.Diagnostics.Process.Start(path);
See Also