GemBox.Document
  • Overview
  • Examples
  • Free version
  • Support
  • Pricelist

    Show / Hide Table of Contents

    ListItem Class

    Namespace:
    GemBox.Document
    Assembly:
    GemBox.Document.dll

    Represents content which prefixes numbered paragraph (Paragraph for which IsList is true).

    • C#
    • VB.NET
    public sealed class ListItem
    Public NotInheritable Class ListItem
    Inheritance:
    System.Object
    ListItem
    Remarks

    List (for example, ordered - with numbers, or unordered - with bullets) appearance in GemBox.Document is defined through ListFormat class that is set on Paragraph's ListFormat property or ParagraphStyle's ListFormat property.

    ListFormat is different from other formats (ParagraphFormat and CharacterFormat) because it doesn't directly contain any formatting properties.

    It contains a reference to a ListStyle which exposes ListLevelFormats for every list (indentation) level through its ListLevelFormats property.

    ListLevelFormats contain direct formatting properties that affect the appearance of the list. Every ListStyle contains exactly 9 ListLevelFormats, one for each possible list (indentation) level.

    Paragraph's list (indentation) level can be adjusted with ListLevelNumber property. Paragraph's list-related formatting will then be collected from the ListLevelFormat instance contained in the ListLevelFormats at the position ListLevelNumber. This ListLevelFormat can also be retrieved from the ListLevelFormat property.

    ListLevelFormat retrieved from the ListLevelFormat property can be additionally modified to enable overriding property values of ListLevelFormat instance contained in the ListLevelFormats at the position ListLevelNumber on a Paragraph or ParagraphStyle basis.

    To create a list in a document, first ListStyle instance has to be created from one of the predefined list style types specified with ListTemplateType enumeration. After that, ListFormat can be created with a specified ListStyle and assigned to a Paragraph's ListFormat property. For a complete example, see Lists example.

    If ListStyle is not referenced from anywhere in the document (from any Paragraph or ParagraphStyle, then it won't be saved to a Word Document (DOCX) file, unless it is added to Styles collection.

    Paragraph's list content, which prefixes paragraph content, is represented by ListItem type.

    ListItems are not permanently stored in model nor they are written to file formats which fully support ListFormat, instead they are recreated each time CalculateListItems() method is called.

    If document content or formatting is changed, then CalculateListItems() method should be called again to retrieve the latest list items.

    For convenience, after calling CalculateListItems() method, ListItem can also be retrieved from ListItem property.

    After calling System.IDisposable.Dispose() on System.Collections.Generic.IEnumerator<T> instance retrieved by calling System.Collections.Generic.IEnumerable<T>.GetEnumerator() on instance returned from CalculateListItems() method, paragraph's ListItem property will be null even if paragraph's IsList is true. This enables easy iteration over ListItems returned from CalculateListItems() method by using foreach statement and removing all references to ListItems after the iteration is finished.

    Properties

    Element

    Gets the paragraph which this ListItem prefixes or ListNum field whose value is this ListItem.

    • C#
    • VB.NET
    public Element Element { get; }
    Public ReadOnly Property Element As Element
    Property Value
    Element

    The paragraph which this ListItem prefixes or ListNum field whose value is this ListItem.

    Inlines

    Gets the content of this ListItem instance.

    • C#
    • VB.NET
    public InlineCollection Inlines { get; }
    Public ReadOnly Property Inlines As InlineCollection
    Property Value
    InlineCollection

    The content of this ListItem instance.

    Numbers

    Gets the list of numbers calculated by counting list paragraphs and their indentation levels.

    • C#
    • VB.NET
    public IList<int> Numbers { get; }
    Public ReadOnly Property Numbers As IList(Of Integer)
    Property Value
    System.Collections.Generic.IList<System.Int32>

    The list of numbers calculated by counting list paragraphs and their indentation levels.

    Paragraph

    Gets the paragraph which this ListItem prefixes or null if this ListItem represents the value of a ListNum field.

    • C#
    • VB.NET
    public Paragraph Paragraph { get; }
    Public ReadOnly Property Paragraph As Paragraph
    Property Value
    Paragraph

    The paragraph which this ListItem prefixes or null if this ListItem represents the value of a ListNum field.

    Methods

    ToString()

    Returns a textual representation of this ListItem instance.

    • C#
    • VB.NET
    public override string ToString()
    Public Overrides Function ToString As String
    Returns
    System.String

    A textual representation of this ListItem instance.

    Overrides
    System.Object.ToString()
    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.