Working with lists and Sublists

Hi Aspose Team

Please refer below question

Working with List and sublists ?

I also need same requirement like the above.

Please provide solution as soon as possible.

Thanks in advance.

Hi,

Thanks for your interest in Aspose.Words. Aspose.Words provides various classes to deal with Lists.
https://reference.aspose.com/words/net/aspose.words.lists/

Also, please try executing the following code to achieve this:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.ListFormat.List = doc.Lists.Add(ListTemplate.NumberDefault);
builder.Writeln("Main Section1");
builder.ListFormat.ListIndent();
builder.ListFormat.ListLevel.NumberStyle = NumberStyle.Arabic;
builder.ListFormat.ListLevel.NumberFormat = "\x0000.\x0001";
builder.Writeln("Sub Section1.1 ");
builder.ListFormat.ListIndent();
builder.ListFormat.ListLevel.NumberStyle = NumberStyle.Arabic;
builder.ListFormat.ListLevel.NumberFormat = "\x0000.\x0001.\x0002";
builder.Writeln("Sub Section 1.1.1");
builder.ListFormat.ListOutdent();
builder.Writeln("Sub Section 1.2 ");
builder.ListFormat.ListOutdent();
builder.Writeln("Main Section2");
builder.ListFormat.ListIndent();
builder.Writeln("Sub Section2.1");
builder.ListFormat.RemoveNumbers();
doc.Save(MyDir + @"out.docx");

I hope, this helps.

Best regards,

Hi
Thanks for your replay.
I want to add font style for list level numbers.
Like 1 in BOLD font (OR) 1.1 in BOLD (OR) 1.1.1 in BOLD etc.
Please help me to solve this problem.

Hi Aspose Support Team,

I also need same requirement like in the 564283 in reply to 563429(Working with lists and sub lists)Post.
Please provide solution for the above post,as soon as possible.

Thanks in advance.

Hi,

Thanks for your inquiry.You can do the formatting by using the Font properties of ListLevel. For example, please see the following code:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.ListFormat.List = doc.Lists.Add(ListTemplate.NumberDefault);
builder.ListFormat.ListLevel.Font.Bold = true;
builder.ListFormat.ListLevel.Font.Color = Color.Red;
builder.Writeln("Main Section1");
builder.ListFormat.ListIndent();
builder.ListFormat.ListLevel.Font.Italic = true;
builder.ListFormat.ListLevel.Font.Color = Color.Green;
builder.ListFormat.ListLevel.NumberStyle = NumberStyle.Arabic;
builder.ListFormat.ListLevel.NumberFormat = "\x0000.\x0001";
builder.Writeln("Sub Section1.1 ");
builder.ListFormat.ListIndent();
builder.ListFormat.ListLevel.Font.Underline = Underline.Dash;
builder.ListFormat.ListLevel.Font.Color = Color.Blue;
builder.ListFormat.ListLevel.NumberStyle = NumberStyle.Arabic;
builder.ListFormat.ListLevel.NumberFormat = "\x0000.\x0001.\x0002";
builder.Writeln("Sub Section 1.1.1");
builder.ListFormat.ListOutdent();
builder.Writeln("Sub Section 1.2 ");
builder.ListFormat.ListOutdent();
builder.Writeln("Main Section2");
builder.ListFormat.ListIndent();
builder.Writeln("Sub Section2.1");
builder.ListFormat.RemoveNumbers();
doc.Save(MyDir + @"out.docx");

I hope, this helps.

Best regards,