Item
Innehåll
[
Dölj
]ListCollection indexer
Hämtar en lista efter index.
public List this[int index] { get; }
Exempel
Visar hur man verifierar ägardokumentegenskaper för listor.
Document doc = new Document();
ListCollection lists = doc.Lists;
Assert.AreEqual(doc, lists.Document);
List list = lists.Add(ListTemplate.BulletDefault);
Assert.AreEqual(doc, list.Document);
Console.WriteLine("Current list count: " + lists.Count);
Console.WriteLine("Is the first document list: " + (lists[0].Equals(list)));
Console.WriteLine("ListId: " + list.ListId);
Console.WriteLine("List is the same by ListId: " + (lists.GetListByListId(1).Equals(list)));
Visar hur man tillämpar listformatering av en befintlig lista på en samling stycken.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Writeln("Paragraph 1");
builder.Writeln("Paragraph 2");
builder.Write("Paragraph 3");
NodeCollection paras = doc.GetChildNodes(NodeType.Paragraph, true);
Assert.AreEqual(0, paras.Count(n => (n as Paragraph).ListFormat.IsListItem));
doc.Lists.Add(ListTemplate.NumberDefault);
List list = doc.Lists[0];
foreach (Paragraph paragraph in paras.OfType<Paragraph>())
{
paragraph.ListFormat.List = list;
paragraph.ListFormat.ListLevelNumber = 2;
}
Assert.AreEqual(3, paras.Count(n => (n as Paragraph).ListFormat.IsListItem));
Se även
- class List
- class ListCollection
- namnutrymme Aspose.Words.Lists
- hopsättning Aspose.Words