ListFormat Class
Allows to control what list formatting is applied to a paragraph.
Inheritance Hierarchy
SystemObject
  Aspose.WordsListFormat

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.9
Syntax
public class ListFormat

The ListFormat type exposes the following members.

Properties
  NameDescription
Public propertyCode exampleIsListItem
True when the paragraph has bulleted or numbered formatting applied to it.
Public propertyCode exampleList
Gets or sets the list this paragraph is a member of.
Public propertyCode exampleListLevel
Returns the list level formatting plus any formatting overrides applied to the current paragraph.
Public propertyCode exampleListLevelNumber
Gets or sets the list level number (0 to 8) for the paragraph.
Methods
  NameDescription
Public methodCode exampleApplyBulletDefault
Starts a new default bulleted list and applies it to the paragraph.
Public methodCode exampleApplyNumberDefault
Starts a new default numbered list and applies it to the paragraph.
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the type of the current instance.
(Inherited from Object.)
Public methodCode exampleListIndent
Increases the list level of the current paragraph by one level.
Public methodCode exampleListOutdent
Decreases the list level of the current paragraph by one level.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodCode exampleRemoveNumbers
Removes numbers or bullets from the current paragraph and sets list level to zero.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Remarks

A paragraph in a Microsoft Word document can be bulleted or numbered. When a paragraph is bulleted or numbered, it is said that list formatting is applied to the paragraph.

You do not create objects of the ListFormat class directly. You access ListFormat as a property of another object that can have list formatting associated with it. At the moment the objects that can have list formatting are: Paragraph, Style and DocumentBuilder.

ListFormat of a Paragraph specifies what list formatting and list level is applied to that particular paragraph.

ListFormat of a Style (applicable to paragraph styles only) allows to specify what list formatting and list level is applied to all paragraphs of that particular style.

ListFormat of a DocumentBuilder provides access to the list formatting at the current cursor position inside the DocumentBuilder.

The list formatting itself is stored inside a List object that is stored separately from the paragraphs. The list objects are stored inside a ListCollection collection. There is a single ListCollection collection per Document.

The paragraphs do not physically belong to a list. The paragraphs just reference a particular list object via the List property and a particular level in the list via the ListLevelNumber property. By setting these two properties you control what bullets and numbering is applied to a paragraph.

Examples
Shows how to specify list level number when building a list using DocumentBuilder.
[C#]

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Create a numbered list based on one of the Microsoft Word list templates and
// apply it to the current paragraph in the document builder.
builder.ListFormat.List = doc.Lists.Add(ListTemplate.NumberArabicDot);

// There are 9 levels in this list, lets try them all.
for (int i = 0; i < 9; i++)
{
    builder.ListFormat.ListLevelNumber = i;
    builder.Writeln("Level " + i);
}

// Create a bulleted list based on one of the Microsoft Word list templates
// and apply it to the current paragraph in the document builder.
builder.ListFormat.List = doc.Lists.Add(ListTemplate.BulletDiamonds);

// There are 9 levels in this list, lets try them all.
for (int i = 0; i < 9; i++)
{
    builder.ListFormat.ListLevelNumber = i;
    builder.Writeln("Level " + i);
}

// This is a way to stop list formatting. 
builder.ListFormat.List = null;

builder.Document.Save(ArtifactsDir + "Lists.SpecifyListLevel.doc");
See Also