Bookmark.LastColumn property

Gets the zero-based index of the last column of the table column range associated with the bookmark.

public int LastColumn { get; }


Returns -1 if this bookmark is not a table column bookmark.


Shows how to get information about table column bookmarks.

Document doc = new Document(MyDir + "Table column bookmarks.doc");

foreach (Bookmark bookmark in doc.Range.Bookmarks)
    // If a bookmark encloses columns of a table, it is a table column bookmark, and its IsColumn flag set to true.
    Console.WriteLine($"Bookmark: {bookmark.Name}{(bookmark.IsColumn ? " (Column)" : "")}");
    if (bookmark.IsColumn)
        if (bookmark.BookmarkStart.GetAncestor(NodeType.Row) is Row row &&
            bookmark.FirstColumn < row.Cells.Count)
            // Print the contents of the first and last columns enclosed by the bookmark.

See Also