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

Creating a bulleted list in code-behind

1 Answer 191 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
GEB
Top achievements
Rank 1
GEB asked on 15 Sep 2010, 08:10 PM
I am creating a document in code-behind, but have not been successful in creating a bulleted list.  Here is a snippet of code.  The text is displayed currectly, but no bullets are generated.

Section section;
Paragraph paragraph;
//  Set up the initial document.
RadDocument document = new RadDocument();
document.LayoutMode = DocumentLayoutMode.Flow;
document.ParagraphDefaultSpacingBefore = 0;
document.ParagraphDefaultSpacingAfter = 0;
//  Set up the section that will contain the list of items.
section = new Section();
section.PageMargin = new Padding(20,0,0,0);
document.Sections.Add(section);
if (myList.Count > 0)
{
    foreach (Item item in myList)
    {
        paragraph = new Paragraph();
        paragraph.ListItemSerializationInfo = new ListItemSerializationInfo() 
            {
                 ListID = 1,
                 ListSymbol = '•',
                 ListType = ListType.Bulleted,
                 SymbolFontSize = 11
            };
        paragraph.Inlines.Add(new Span()
            {
                Text = item.Description,
                FontSize = 11,
                ForeColor = Colors.Black
            });
        section.Paragraphs.Add(paragraph);
    }
}

1 Answer, 1 is accepted

Sort by
0
Ivailo Karamanolev
Telerik team
answered on 16 Sep 2010, 07:31 AM
Hi GEB,

The correct way to add paragraphs to a list (numbered, bulleted...) is to create an instance of the list, e.g.
BulletedList list = new BulletedList();
or
NumberedList list = new NumberedList();
and then call
list.Add(paragraph);
for every paragraph you want to add to the list.

I hope this is helpful, feel free to contact us if you need any further assistance.

Kind regards,
Ivailo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
RichTextBox
Asked by
GEB
Top achievements
Rank 1
Answers by
Ivailo Karamanolev
Telerik team
Share this question
or