Free Support Forum - aspose.com

I would like to create a multi-level list-then set into paragraph

I would like to create a multi-level list,Style is as follows:

1
1.1
1.1.1
1.1.1.1
and then set a multilevel list into paragraphs, can give you a code?
Aspose.Words.Lists.List list1 = doca.Lists.Add(Aspose.Words.Lists.ListTemplate.NumberArabicParenthesis);
list1.ListLevels[0].NumberFormat = "%1 ";
list1.ListLevels[1].NumberFormat = "%1.%2 ";
list1.ListLevels[2].NumberFormat = "%1.%2.%3 ";
list1.ListLevels[3].NumberFormat = "%1.%2.%3.%4 ";
paragraph.ListFormat.List = list1;
paragraph.ListFormat.List = list1;
doca.Save(@“c:\d2.docx”, SaveFormat.Docx);No success
Hi,

Thanks for your inquiry. Please use following code snippet for your requirement. Hope this helps you. Please let us know if you have any more queries.

Document doc = new Document();

// Create a list based on one of the Microsoft Word list templates.

Aspose.Words.Lists.List list = doc.Lists.Add(ListTemplate.NumberDefault);

// Completely customize one list level.

ListLevel level1 = list.ListLevels[0];

level1.NumberStyle = NumberStyle.OrdinalText;

level1.NumberFormat = "1";

// Completely customize yet another list level.

ListLevel level2 = list.ListLevels[1];

level2.NumberFormat = "1.1";

// Completely customize yet another list level.

ListLevel level3 = list.ListLevels[2];

level3.NumberFormat = "1.1.1";

DocumentBuilder builder = new DocumentBuilder(doc);

builder.ListFormat.List = list;

builder.Writeln("The quick brown fox...");

builder.ListFormat.ListIndent();

builder.Writeln("jumped over the lazy dog.");

builder.ListFormat.ListIndent();

builder.Writeln("jumped over the lazy dog.");

builder.ListFormat.ListOutdent();

builder.Writeln("The quick brown fox...");

builder.ListFormat.RemoveNumbers();

builder.Document.Save(MyDir + "Lists.CreateCustomList Out.doc");