Skip to end of metadata
Go to start of metadata

Lists

To add a list to a section of your document, use one of the following methods. All of the methods insert a list at a specified point in an Element. An Element object represents an editable region in a document, such as a section or a table cell. The document itself is an Element (the Document class extends Element). Later, we will add a list to a Document object.
  • Inserts an empty list at the end of the specified Element. Pass true to the method to create a numbered list, and false to create a bulleted list.

  • Inserts an empty list at the beginning of the specified Element. Pass true to the method to create a numbered list, and false to create a bulleted list.

  • Inserts an empty list at a specified position within an Element. A Position object represents a cursor. Pass true to the method to create a numbered list, and false to create a bulleted list.

Before adding a list to your file, you must create a content region in which to insert the list. Each editable region in a Word file is represented by an Element object, or an object that extends Element, such as a Document object.

To insert an empty list, use one of the methods listed at the beginning of this section, for example:

Next, create list entries. To add a new entry, call either List.AddEntry or List.InsertEntry.

To add text to a list entry call one of the Element class's InsertTextAfter or InsertTextBefore methods. You can apply a font to the text by passing a Font object to InsertTextAfter or InsertTextBefore. The following lines create a Font object that we will use later when adding text to the paragraph:

The method InsertTextAfter takes a string and inserts it at the end of the list entry. The method's second parameter specifies a Font object (created above) to apply to the text.

You can access existing lists through the Element.Elements property.

See Also

List

ListEntry

ListLevel

  • No labels