ListLevel

ListLevel class

Defines formatting for a list level.

public class ListLevel

Properties

Name Description
Alignment { get; set; } Gets or sets the justification of the actual number of the list item.
CustomNumberStyleFormat { get; } Gets the custom number style format for this list level. For example: “a, ç, ĝ, …”.
Font { get; } Specifies character formatting used for the list label.
ImageData { get; } Returns image data of the picture bullet shape for the current list level.
IsLegal { get; set; } True if the level turns all inherited numbers to Arabic, false if it preserves their number style.
LinkedStyle { get; set; } Gets or sets the paragraph style that is linked to this list level.
NumberFormat { get; set; } Returns or sets the number format for the list level.
NumberPosition { get; set; } Returns or sets the position (in points) of the number or bullet for the list level.
NumberStyle { get; set; } Returns or sets the number style for this list level.
RestartAfterLevel { get; set; } Sets or returns the list level that must appear before the specified list level restarts numbering.
StartAt { get; set; } Returns or sets the starting number for this list level.
TabPosition { get; set; } Returns or sets the tab position (in points) for the list level.
TextPosition { get; set; } Returns or sets the position (in points) for the second line of wrapping text for the list level.
TrailingCharacter { get; set; } Returns or sets the character inserted after the number for the list level.

Methods

Name Description
CreatePictureBullet() Creates picture bullet shape for the current list level.
DeletePictureBullet() Deletes picture bullet for the current list level.
Equals(ListLevel) Compares with the specified ListLevel.
override GetHashCode() Calculates hash code for this object.
static GetEffectiveValue(int, NumberStyle, string) Reports the string representation of the ListLevel object for the specified index of the list item. Parameters specify the NumberStyle and an optional format string used when Custom is specified.

Remarks

You do not create objects of this class. List level objects are created automatically when a list is created. You access ListLevel objects via the ListLevelCollection collection.

Use the properties of ListLevel to specify list formatting for individual list levels.

Examples

Shows how to apply custom list formatting to paragraphs when using DocumentBuilder.

Document doc = new Document();

// A list allows us to organize and decorate sets of paragraphs with prefix symbols and indents.
// We can create nested lists by increasing the indent level. 
// We can begin and end a list by using a document builder's "ListFormat" property. 
// Each paragraph that we add between a list's start and the end will become an item in the list.
// Create a list from a Microsoft Word template, and customize the first two of its list levels.
List list = doc.Lists.Add(ListTemplate.NumberDefault);

ListLevel listLevel = list.ListLevels[0];
listLevel.Font.Color = Color.Red;
listLevel.Font.Size = 24;
listLevel.NumberStyle = NumberStyle.OrdinalText;
listLevel.StartAt = 21;
listLevel.NumberFormat = "\x0000";

listLevel.NumberPosition = -36;
listLevel.TextPosition = 144;
listLevel.TabPosition = 144;

listLevel = list.ListLevels[1];
listLevel.Alignment = ListLevelAlignment.Right;
listLevel.NumberStyle = NumberStyle.Bullet;
listLevel.Font.Name = "Wingdings";
listLevel.Font.Color = Color.Blue;
listLevel.Font.Size = 24;

// This NumberFormat value will create star-shaped bullet list symbols.
listLevel.NumberFormat = "\xf0af";
listLevel.TrailingCharacter = ListTrailingCharacter.Space;
listLevel.NumberPosition = 144;

// Create paragraphs and apply both list levels of our custom list formatting to them.
DocumentBuilder builder = new DocumentBuilder(doc);

builder.ListFormat.List = list;
builder.Writeln("The quick brown fox...");
builder.Writeln("The quick brown fox...");

builder.ListFormat.ListIndent();
builder.Writeln("jumped over the lazy dog.");
builder.Writeln("jumped over the lazy dog.");

builder.ListFormat.ListOutdent();
builder.Writeln("The quick brown fox...");

builder.ListFormat.RemoveNumbers();

builder.Document.Save(ArtifactsDir + "Lists.CreateCustomList.docx");

See Also