Forums     Knowledge Base     OfficeWriter Online     
 
 
This documentation is for
OfficeWriter v3.8.1
.NET Platform

View Docs for Another
Version or Platform

Programmer's Reference > WordApplication API > List

The List Object

     extends Element



This class is used to represent a list in a Word document. Lists are part of the BlockElements of an Element. Using this class, Lists can be read and written. Lists contain list entries, which are basically paragraphs with additional features.

To create a new list, use Element.InsertListBefore() or Element.InsertListAfter(). To get an existing list, use Element.getElements(Element.Type.List).

The following sample demonstrates how to create a new list at the end of a document as well as how to get the first list of a document.



Examples:

[csharp]
// Insert a numbered list at the end of a new document with one entry
WordApplication app = new WordApplication();
Document doc = app.Create();
List lst = doc.InsertListAfter(true);
lst.AddEntry(0);
lst.InsertTextAfter("First list entry.", false);

// Get the first list of an existing document
WordApplication app = new WordApplication();
Document doc = app.Open(@"C:\sample.doc");
List lst = doc.Elements(Element.Type.List)[0];
[vbnet]
' Insert a numbered list at the end of a new document with one entry
Dim app As New WordApplication()
Dim doc As Document = app.Create()
Dim lst As List = doc.InsertListAfter(True)
lst.AddEntry(0)
lst.InsertTextAfter("First list entry.", False)

' Get the first list of an existing document
Dim app As New WordApplication()
Dim doc As Document = app.Open("C:\sample.doc")
Dim lst As List = doc.Elements(Element.Type.List)(0)


Please note that this object inherits methods and properties not shown here from the following objects:

List Properties

Property Type Access Description
NumEntries int read

Returns an int representing the number of contiguous entries in this lst



List Methods

ReturnsSignature and Description
ListEntry AddEntry ( int level )

Returns a ListEntry object representing an empty list entry added to the end of the list, which is indented to the level specified

ListEntry GetEntry ( int index )

Returns a ListEntry object representing the entry at a specified index

ListLevel GetLevel ( int level )

Returns a ListLevel object representing a particular level for this lst

ListEntry InsertEntry ( int index , int level )

Returns ListEntry object representing an empty list entry that is inserted at the given index, which is indented to the level specified



Copyright 2007 © SoftArtisans, Inc. All Rights Reserved.