Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Class

WordList

OfficeIMO.Word

Namespace
OfficeIMO.Word
Assembly
OfficeIMO.Word
Source revision
0eef6a5756b9 with working tree changes

Represents a collection of paragraphs formatted as a list and exposes methods to manipulate the list's numbering and style.

Inheritance

Usage

Explore 21 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Accepted by parameters 2

Constructors

WordList 4 overloads
public WordList(WordDocument wordDocument, bool isToc = false) #

Initializes a new instance of the WordList class.

Parameters

wordDocument OfficeIMO.Word.WordDocument required
The Word document.
isToc bool = false optional
Indicates if the list should be treated as a TOC.
public WordList(WordDocument wordDocument, WordParagraph paragraph, bool isToc = false) #

Initializes a new instance of the WordList class with a starting paragraph.

Parameters

wordDocument OfficeIMO.Word.WordDocument required
The Word document.
paragraph OfficeIMO.Word.WordParagraph required
The starting paragraph.
isToc bool = false optional
Indicates if the list should be treated as a TOC.
public WordList(WordDocument wordDocument, int numberId) #

Initializes a new instance of the WordList class with a specific number ID.

Parameters

wordDocument OfficeIMO.Word.WordDocument required
The Word document.
numberId int required
The numbering ID.
public WordList(WordDocument wordDocument, WordHeaderFooter headerFooter) #

Initializes a new instance of the WordList class for headers and footers.

Parameters

wordDocument OfficeIMO.Word.WordDocument required
The Word document.
headerFooter OfficeIMO.Word.WordHeaderFooter required
The header or footer.

Methods

AddCustomBulletList 3 overloads
public static WordList AddCustomBulletList(WordDocument document, char symbol, string fontFamily, OfficeColor? color, OfficeLength? fontSize = null) #

Creates a bulleted list using a custom symbol and formatting.

Parameters

document OfficeIMO.Word.WordDocument required
The parent document.
symbol char required
The character to use as the bullet symbol.
fontFamily string required
Font family used for the bullet symbol.
color OfficeIMO.OfficeColor? required
Optional color for the symbol.
fontSize OfficeIMO.OfficeLength? = null optional
Optional font size for the symbol.

Returns

WordList The created WordList.
public static WordList AddCustomBulletList(WordDocument document, WordBulletSymbol symbol, string fontFamily, OfficeColor? color = null, OfficeLength? fontSize = null) #

Creates a custom bulleted list using a predefined WordBulletSymbol.

Parameters

document OfficeIMO.Word.WordDocument required
The parent document.
symbol OfficeIMO.Word.WordBulletSymbol required
Predefined bullet symbol to use.
fontFamily string required
Font family used for the symbol.
color OfficeIMO.OfficeColor? = null optional
Optional OfficeColor for the symbol.
fontSize OfficeIMO.OfficeLength? = null optional
Optional font size in points.

Returns

WordList The created WordList.
public static WordList AddCustomBulletList(WordDocument document, WordListLevelKind kind, string fontFamily, OfficeColor? color = null, OfficeLength? fontSize = null) #

Creates a bulleted list using one of the predefined WordListLevelKind values.

Parameters

document OfficeIMO.Word.WordDocument required
The parent document.
kind OfficeIMO.Word.WordListLevelKind required
Determines which bullet symbol to use.
fontFamily string required
Font family used for the symbol.
color OfficeIMO.OfficeColor? = null optional
Optional symbol color.
fontSize OfficeIMO.OfficeLength? = null optional
Optional font size in points.

Returns

WordList The created WordList.
public static WordList AddCustomList(WordDocument document) #

Creates a list that does not contain any predefined levels. Levels can be configured manually after creation.

Parameters

document OfficeIMO.Word.WordDocument required
Parent document where the list will be added.

Returns

WordList The created WordList.
AddItem 2 overloads
public WordParagraph AddItem(WordParagraph? wordParagraph, int level = 0) #

Adds a new empty item to the list.

Parameters

wordParagraph OfficeIMO.Word.WordParagraph? required
The paragraph after which the item should be inserted. If null the item is appended at the default position.
level int = 0 optional
The zero-based list level for the new item.

Returns

WordParagraph The newly created WordParagraph representing the list item.
public WordParagraph AddItem(string? text, int level = 0, WordParagraph? wordParagraph = null) #

Adds a new item to the list and optionally sets its text.

Parameters

text string? required
Text to assign to the new list item. Pass null to insert an empty item.
level int = 0 optional
The zero-based list level for the item.
wordParagraph OfficeIMO.Word.WordParagraph? = null optional
The paragraph after which the item is inserted. When null the item is appended in the default position.

Returns

WordParagraph The WordParagraph representing the created list item.
public WordParagraph AddLinkItem(string text, Uri destination, bool addStyle = false, int level = 0) #

Adds an item whose text links to the supplied destination.

Parameters

text string required
destination System.Uri required
addStyle bool = false optional
level int = 0 optional
AddListLevel 3 overloads
public WordListLevel AddListLevel(int levelIndex, char symbol, string fontFamily, OfficeColor? color, OfficeLength? fontSize = null) #

Adds a new bullet list level using a custom symbol character.

Parameters

levelIndex int required
Index of the level starting from 1.
symbol char required
Character used for the bullet.
fontFamily string required
Font family used for the symbol.
color OfficeIMO.OfficeColor? required
Bullet color.
fontSize OfficeIMO.OfficeLength? = null optional
Optional font size.

Returns

WordListLevel The newly attached WordListLevel.
public WordListLevel AddListLevel(int levelIndex, WordBulletSymbol symbol, string fontFamily, OfficeColor? color = null, OfficeLength? fontSize = null) #

Adds a new bullet list level using a predefined WordBulletSymbol.

Parameters

levelIndex int required
Index of the level starting from 1.
symbol OfficeIMO.Word.WordBulletSymbol required
Predefined bullet symbol.
fontFamily string required
Font family used for the symbol.
color OfficeIMO.OfficeColor? = null optional
Optional symbol color.
fontSize OfficeIMO.OfficeLength? = null optional
Optional font size in points.

Returns

WordListLevel The newly attached WordListLevel.
public WordListLevel AddListLevel(int levelIndex, WordListLevelKind kind, string fontFamily, OfficeColor? color = null, OfficeLength? fontSize = null) #

Adds a new bullet list level using one of the predefined WordListLevelKind values.

Parameters

levelIndex int required
Index of the level starting from 1.
kind OfficeIMO.Word.WordListLevelKind required
Determines which bullet symbol to use.
fontFamily string required
Font family used for the symbol.
color OfficeIMO.OfficeColor? = null optional
Optional symbol color.
fontSize OfficeIMO.OfficeLength? = null optional
Optional font size in points.

Returns

WordListLevel The newly attached WordListLevel.

Examples

WordList list = document.AddCustomList();
list.AddListLevel(1, WordListLevelKind.BulletSquareSymbol, "Courier New", color: OfficeIMO.OfficeColor.Parse("#FF0000"), fontSize: global::OfficeIMO.OfficeLength.Points(14));
list.AddListLevel(2, WordListLevelKind.BulletBlackCircle, "Arial", color: OfficeIMO.OfficeColor.Parse("#00FF00"), fontSize: global::OfficeIMO.OfficeLength.Points(10));

list.AddItem("Top level");
list.AddItem("Nested level", 1);
AddPictureBulletList 2 overloads
public static WordList AddPictureBulletList(WordDocument document, Stream imageStream, string fileName) #

Creates a custom bullet list using an image as the bullet symbol.

Parameters

document OfficeIMO.Word.WordDocument required
Parent document where the list will be added.
imageStream System.IO.Stream required
Stream containing the image data.
fileName string required
File name used to determine the image type.

Returns

WordList The created WordList.
public static WordList AddPictureBulletList(WordDocument document, string imagePath) #

Creates a custom bullet list using an image file as the bullet symbol.

Parameters

document OfficeIMO.Word.WordDocument required
Parent document where the list will be added.
imagePath string required
Path to the image file.

Returns

WordList The created WordList.
public WordParagraph AddTaskItem(string text, bool done = false, int level = 0) #

Adds a task item containing an editable checkbox and text.

Parameters

text string required
done bool = false optional
level int = 0 optional
Clone 2 overloads
public WordList Clone() #

Creates a copy of this list after the last item.

Returns

WordList The newly created WordList.

Exceptions

  • InvalidOperationException – Thrown when the list contains no items.
public WordList Clone(WordParagraph paragraph, bool after = true) #

Clones this list and inserts it relative to the provided paragraph.

Parameters

paragraph OfficeIMO.Word.WordParagraph required
The reference paragraph used for insertion.
after bool = true optional
If set to true the clone is inserted after the reference paragraph; otherwise it is inserted before.

Returns

WordList The cloned WordList.
public void ConvertToBulleted() #

Converts this list to a bulleted style while preserving existing list items.

public void ConvertToNumbered() #

Converts this list to a numbered style while preserving existing list items.

public void Merge(WordList documentList) #

Merges another list into this list.

Parameters

documentList OfficeIMO.Word.WordList required
The list whose items should be moved into this instance.
public void Remove() #

Removes the list from the document including all list items.

public void SetStartNumberingValue(int value, int level = 0) #

Sets the starting number for the specified list level. Updates both the abstract definition and the list instance override.

Parameters

value int required
Starting number for the level.
level int = 0 optional
Zero-based list level.

Examples

WordList list = document.AddCustomList();
list.Numbering.AddLevel(new WordListLevel(WordListLevelKind.Decimal));
list.SetStartNumberingValue(3);
list.AddItem("Starts at three");

Properties

public bool IsToc { get; } #

Indicates whether the list is treated as a Table of Contents (TOC).

public List<WordParagraph> ListItems { get; } #

Gets all the list items associated with this WordList.

public bool RestartNumberingAfterBreak { get; set; } #

Restarts numbering of a list after a break. Requires a list to be set to RestartNumbering overall.

public WordListNumbering Numbering { get; } #

Exposes the numbering properties of the list, allowing for customization.

public bool Bold { get; set; } #

Gets or sets a value indicating whether the numbering symbols are bold.

public OfficeLength? FontSize { get; set; } #

Gets or sets the font size of the numbering symbols in points.

public OfficeColor? Color { get; set; } #

Gets or sets the color of the numbering symbols. Setting null removes the color.

public bool Italic { get; set; } #

Gets or sets a value indicating whether the numbering symbols are italicized.

public WordUnderlineStyle? Underline { get; set; } #

Gets or sets the underline style of the numbering symbols.

public bool Strikethrough { get; set; } #

Gets or sets a value indicating whether the numbering symbols have a strikethrough.

public bool DoubleStrikethrough { get; set; } #

Gets or sets a value indicating whether the numbering symbols have a double strikethrough.

public string? FontFamily { get; set; } #

Gets or sets the font family of the numbering symbols; null when none is set.

public WordListStyle Style { get; } #

Gets the list style or WordListStyle.Custom when the list does not match a built-in style.