This is a migrated thread and some comments may be shown as answers.

Modify ListStyle Numbering Format

2 Answers 80 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
deri
Top achievements
Rank 1
deri asked on 21 Sep 2016, 04:21 AM

hello,

For some reason i have to create custom liststyle based on existing one. You can find the detail in the attached picture. So is it possible to create these things? I've spent almost a a week and still stuck in this mess.

thanks in advance, and sorry for my bad english.

Deri.

2 Answers, 1 is accepted

Sort by
0
Deyan
Telerik team
answered on 23 Sep 2016, 01:29 PM
Hello Deri,

Thank you for contacting us.

In this ListStyle documentation  you can find description on how to build custom list appearance. Basically, the numbering representation depends on ListLevelStyle NumberingFormat and LevelText properties. Using UpperLetter numbering format and appropriate level text you may make numbers appear as "AAA", "BBB", "CCC". However, there is no numbering format allowing you to convert numbers to the words "ONE", "TWO", "THREE". With the following code, you may create custom list style and build document similar to the attached screenshot:
RadDocument document = this.radRichTextBox.Document;
RadDocumentEditor editor = new RadDocumentEditor(document);
ListStyle listStyle = new ListStyle();
 
for (int i = 0; i < 9; i++)
{
    bool isEven = (i & 1) == 0;
    ListLevelStyle listLevel = new ListLevelStyle();
    listLevel.StartingIndex = 1;
    listLevel.NumberingFormat = isEven ? ListNumberingFormat.UpperLetter : ListNumberingFormat.Decimal;
    listLevel.Indent = 48 + (24 * i);
    listLevel.LevelText = isEven ? string.Format("{0}{1}{2}{0}{1}{2}{0}{1}{2} DOT ", '{', i, '}') : string.Format("{0}{1}{2} DOT ", '{', i, '}');
    listLevel.FontWeight = FontWeights.Bold;
    listStyle.Levels.Add(listLevel);
}
 
editor.ChangeParagraphListStyle(listStyle);
editor.ChangeParagraphListLevel(0);
editor.Insert("First level first item");
editor.InsertParagraph();
editor.ChangeParagraphListLevel(1);
editor.Insert("Second level first item");
editor.InsertParagraph();
editor.Insert("Second level second item");
editor.InsertParagraph();
editor.ChangeParagraphListLevel(2);
editor.Insert("Third level first item");
editor.InsertParagraph();
editor.ChangeParagraphListLevel(1);
editor.Insert("Second level third item");
editor.InsertParagraph();
editor.ChangeParagraphListLevel(0);
editor.Insert("First level second item");
 
editor.InsertParagraph();
editor.ChangeParagraphListStyle(null);
editor.Insert("Some text outside the list.");

I hope this is helpful. If you have any other questions or concerns please do not hesitate to contact us again.

Regards,
Deyan
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
deri
Top achievements
Rank 1
answered on 27 Sep 2016, 04:24 AM

Hi Deyan,

Thanks for response, but i had achieved the result like yours before i had submit this thread. The reason why i have to customize/convert the numbering format to words format is application that i made doesn't allowing to use any number/symbol in the document. Thanks anyway, Telerik documentation is help me a lot from building my apps.

Tags
RichTextBox
Asked by
deri
Top achievements
Rank 1
Answers by
Deyan
Telerik team
deri
Top achievements
Rank 1
Share this question
or