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

Adding ListStyles

5 Answers 99 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Sebastian
Top achievements
Rank 1
Sebastian asked on 18 Feb 2015, 12:18 PM
Hi I tried to add ListStyles to a RadDocument so that they are shown in the RadRichTextBoxRibbonUi.

foreach (var style in listStyles)
            {                               
                ListStyle newList = RadDocument.AddCustomListStyle(style);               
                RadDocument.ListStyles.Add(newList);
                RadDocument.ListManager.RegisterListStyleIfNecessary(newList);                               
            }


That is what I'm doing at the moment but it doesn't works.

5 Answers, 1 is accepted

Sort by
0
Tanya
Telerik team
answered on 19 Feb 2015, 03:57 PM
Hello Sebastian,

You should add the ListStyle to the RadDocument using the DocumentList class. The code snippet below demonstrates how to achieve this:
RadDocument doc = new RadDocument();
ListStyle newListStyle = doc.AddCustomListStyle(list);
DocumentList documentList = new DocumentList(newListStyle, doc);           
this.radRichTextBox.Document = doc;

In addition, more information about lists and list styles you can find in the List Styles article in our documentation.

Regards,
Tanya
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Sebastian
Top achievements
Rank 1
answered on 20 Feb 2015, 11:47 AM
public RadDocument RadDocument
        {
            get
            {
                return this.editor.Document;
            }
            set
            {
                this.editor.Document = value;               
            }
        }
What I've forgot to Post the var RadDocument is the Current RadDocument of my RadRichTextBox
0
Sebastian
Top achievements
Rank 1
answered on 20 Feb 2015, 11:54 AM
foreach (var style in listStyles)
 {                                               
                ListStyle newList = RadDocument.AddCustomListStyle(style);
                DocumentList documentList = new DocumentList(newList, RadDocument);
                RadDocument.ListStyles.Add(newList);
                RadDocument.ListManager.RegisterListStyleIfNecessary(newList);                               
            }
            this.editor.Document = RadDocument;
this is my current cdoe for adding the ListStyles but it doesn't work.
0
Accepted
Tanya
Telerik team
answered on 23 Feb 2015, 11:14 AM
Hi Sebastian,

Please, refer to the snippet below, which is demonstrating how to create a List and add it to the RadDocument:
ListStyle list = new ListStyle();
list.StyleLink = "Numbered";
 
for (int levelIndex = 0; levelIndex < 9; levelIndex++)
{
    bool isEven = (levelIndex % 2) == 0;
    ListLevelStyle level = new ListLevelStyle();
    level.StartingIndex = 1;
    level.NumberingFormat = ListNumberingFormat.Decimal;
    level.LevelText = isEven ? "{" + levelIndex + "}." : "o";
    level.ForeColor = Color.FromRgb(34, 144, 233);
    level.Indent = 48 + (levelIndex * 24);
 
    list.Levels.Add(level);
}
 
RadDocument doc = new RadDocument();
ListStyle newListStyle = doc.AddCustomListStyle(list);
DocumentList documentList = new DocumentList(newListStyle, doc);

If you are still experiencing difficulties with this, it would be great if you sent us more details - what is the code for creating the ListStyles, what is not working - it the style not appearing in the document or you get some an error. If it is possible an example project would be great.

I am looking forward to hearing from you.

Regards,
Tanya
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Sebastian
Top achievements
Rank 1
answered on 24 Feb 2015, 08:57 AM
Thanks it works now.
My misstake was that I doesn't set the StartingIndex and the LevelText of the LevelStyle.
Tags
RichTextBox
Asked by
Sebastian
Top achievements
Rank 1
Answers by
Tanya
Telerik team
Sebastian
Top achievements
Rank 1
Share this question
or