WordList
OfficeIMO.Word
Represents a collection of paragraphs formatted as a list and exposes methods to manipulate the list's numbering and style.
Inheritance
- WordElement
- WordList
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.
Returned or exposed by 19
- Method WordDocument.AddCustomBulletList
- Method WordDocument.AddCustomList
- Method WordDocument.AddList
- Method WordDocument.AddListBulleted
- Method WordDocument.AddListNumbered
- Method WordDocument.AddPictureBulletList
- Method WordDocument.AddTableOfContentList
- Property WordDocument.Lists
- Method WordFooter.AddList
- Method WordHeader.AddList
- Method WordHeaderFooter.AddList
- Method WordList.AddCustomBulletList
- Method WordList.AddCustomList
- Method WordList.AddPictureBulletList
- Method WordList.Clone
- Method WordParagraph.AddList
- Property WordSection.Lists
- Property WordStyle.List
- Method WordTableCell.AddList
Accepted by parameters 2
- Method WordList.Merge
- Method WordStyle.SetList
Constructors
public WordList(WordDocument wordDocument, bool isToc = false) #Initializes a new instance of the WordList class.
Parameters
- wordDocument OfficeIMO.Word.WordDocument
- The Word document.
- isToc bool = false
- 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
- The Word document.
- paragraph OfficeIMO.Word.WordParagraph
- The starting paragraph.
- isToc bool = false
- Indicates if the list should be treated as a TOC.
Methods
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
- The parent document.
- symbol char
- The character to use as the bullet symbol.
- fontFamily string
- Font family used for the bullet symbol.
- color OfficeIMO.OfficeColor?
- Optional color for the symbol.
- fontSize OfficeIMO.OfficeLength? = null
- Optional font size for the symbol.
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
- The parent document.
- symbol OfficeIMO.Word.WordBulletSymbol
- Predefined bullet symbol to use.
- fontFamily string
- Font family used for the symbol.
- color OfficeIMO.OfficeColor? = null
- Optional OfficeColor for the symbol.
- fontSize OfficeIMO.OfficeLength? = null
- Optional font size in points.
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
- The parent document.
- kind OfficeIMO.Word.WordListLevelKind
- Determines which bullet symbol to use.
- fontFamily string
- Font family used for the symbol.
- color OfficeIMO.OfficeColor? = null
- Optional symbol color.
- fontSize OfficeIMO.OfficeLength? = null
- Optional font size in points.
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
- Parent document where the list will be added.
public WordParagraph AddItem(WordParagraph? wordParagraph, int level = 0) #Adds a new empty item to the list.
Parameters
- wordParagraph OfficeIMO.Word.WordParagraph?
- The paragraph after which the item should be inserted. If null the item is appended at the default position.
- level int = 0
- The zero-based list level for the new 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?
- Text to assign to the new list item. Pass null to insert an empty item.
- level int = 0
- The zero-based list level for the item.
- wordParagraph OfficeIMO.Word.WordParagraph? = null
- The paragraph after which the item is inserted. When null the item is appended in the default position.
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
- destination System.Uri
- addStyle bool = false
- level int = 0
Returns
WordParagraphpublic 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
- Index of the level starting from 1.
- symbol char
- Character used for the bullet.
- fontFamily string
- Font family used for the symbol.
- color OfficeIMO.OfficeColor?
- Bullet color.
- fontSize OfficeIMO.OfficeLength? = null
- Optional font size.
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
- Index of the level starting from 1.
- symbol OfficeIMO.Word.WordBulletSymbol
- Predefined bullet symbol.
- fontFamily string
- Font family used for the symbol.
- color OfficeIMO.OfficeColor? = null
- Optional symbol color.
- fontSize OfficeIMO.OfficeLength? = null
- Optional font size in points.
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
- Index of the level starting from 1.
- kind OfficeIMO.Word.WordListLevelKind
- Determines which bullet symbol to use.
- fontFamily string
- Font family used for the symbol.
- color OfficeIMO.OfficeColor? = null
- Optional symbol color.
- fontSize OfficeIMO.OfficeLength? = null
- Optional font size in points.
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);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
- Parent document where the list will be added.
- imageStream System.IO.Stream
- Stream containing the image data.
- fileName string
- File name used to determine the image type.
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
- Parent document where the list will be added.
- imagePath string
- Path to the image file.
public WordParagraph AddTaskItem(string text, bool done = false, int level = 0) #Adds a task item containing an editable checkbox and text.
Parameters
- text string
- done bool = false
- level int = 0
Returns
WordParagraphpublic WordList Clone() #Creates a copy of this list after the last item.
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
- The reference paragraph used for insertion.
- after bool = true
- If set to true the clone is inserted after the reference paragraph; otherwise it is inserted before.
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
- 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
- Starting number for the level.
- level int = 0
- Zero-based list level.
Examples
WordList list = document.AddCustomList();
list.Numbering.AddLevel(new WordListLevel(WordListLevelKind.Decimal));
list.SetStartNumberingValue(3);
list.AddItem("Starts at three");Inherited Methods
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.