Nevron Open Vision Documentation
Bullet Lists

Bullet lists allow you to apply automatic numbering on paragraphs. The following sections will teach you how to work with bullet lists:

Creating Bullet Lists

You create a bullet list by creating an instance of the NBulletList class and assigning it to one or more paragraphs in the document. For example the following code creates a simple numbered bullet list:

Creating Bullet Lists
Copy Code
NBulletList bulletList = new NBulletList(ENBulletListTemplateType.Decimal);
m_RichText.Content.BulletLists.Add(bulletList);
for (int i = 0; i < 3; i++)
{
    NParagraph paragraph = new NParagraph("Bullet List Item " + i.ToString());
    paragraph.SetBulletList(bulletList, 0);
    section.Blocks.Add(paragraph);
}

The generated bullet list will look like:

Bullet Inline

Notice that in the previous section we used the SetBulletList shortcut method to assign bullet list and bullet list level to the paragraph. This information is stored in the Bullet property of the paragraph. The Bullet property holds a reference to an inline text object of type NBulletInline. This inline can contain text and optionally a separator space or tab. The following code shows how to assign those properties from code:

Working with bullet properties
Copy Code

NBulletList bulletList = new NBulletList(ENBulletListTemplateType.Decimal);
m_RichText.Content.BulletLists.Add(bulletList);

for (int i = 0; i < 3; i++)
{
    NParagraph paragraph = new NParagraph("Bullet List Item " + i.ToString());
    NBulletInline bullet = new NBulletInline();
    bullet.List = bulletList;
    bullet.ListLevel = 0;
    paragraph.Bullet = bullet;
    section.Blocks.Add(paragraph);
}

Like with any inline you can modify the text font, fill, style etc. For example:

Working with bullet properties
Copy Code
NBulletInline bullet = new NBulletInline();
bullet.List = bulletList;
bullet.ListLevel = 0;
paragraph.Bullet = bullet;
paragraph.Bullet.Fill = new NColorFill(NColor.Red);

Creates a red bullet list item.

Bullet List

As shown in the above sections the steps to create a bullet list are:

1. Create an instance of the NBulletList class.

2. Add the bullet list to the document BulletLists collection.

3. Assign this bullet list to one or more paragraphs.

Each bullet list consist of one or more levels that you add to the ListLevels collection of that list. Each bullet list level is responsible for formatting the bullets generated by bullet list items for that level. For example if you have two paragraphs where the first one has bullet inline that has ListLevel set to 0 and the second one has a bullet inline that has ListLevel set to 1,  then the bullet generated by the first one will be formatted using the properties of the first bullet list level, whereas the bullet generated by the second one will be formatted using the properties of the second bullet list level. The following code shows how to create a bullet list with single level:

Creating Bullet List with Single Level
Copy Code
NBulletList bulletList = new NBulletList();
NBulletListLevel bulletListLevel = new NBulletListLevel();
bulletListLevel.BulletType = ENBulletType.Decimal;
bulletListLevel.Format += "\\0.";
bulletList.Levels.Add(bulletListLevel);

 

The following sections discuss the properties of the NBulletListLevel class:

Bullet Format

Each bullet list level has a property called Format which allows you to specify the text displayed by the bullets for that level. The string value you pass there can contain either plain characters or backward slash followed by level number. For example in the code above the format is set to "\0.", meaning that the formatted counter value for level 1 is followed by dot. If you create a second bullet list level it will typically use "\0.\1." and so on. In general by placing a back slash followed by level number you create a place holder for formatted counter values, which you can mix with arbitrary characters.

Bullet Type

The bullet list template level has a property called BulletType which controls how counter values are formatted for this particular level. The following table lists the available options:

ENBulletType Description
Text Bullet specified from the bullet char property.
Decimal Arabic numbers - 1, 2, 3, 4, etc.
LowerRoman Lower case roman numbers - i, ii, iii, iv, etc.
UpperRoman Upper case roman numbers - I, II, III, IV, etc.
LowerAlpha Lower case letters - a, b, c, d, etc.
UpperAlpha Upper case letters - A, B, C, D, etc.
OrdinalEnglish Ordinal number - 1st, 2nd, 3rd, 4th, etc.
CardinalTextEnglish Cardinal text number - One, Two Three, Four, etc.
OrdinalTextEnglish Ordinal text number - First, Second, Third, Fourth, etc.

The following example shows how to create a bullet list level that specifies filled circle as the bullet text:

Setting Bullet Type
Copy Code
// create a bullet list template
NBulletList bulletList = new NBulletList();
// create a bullet list template level
NBulletListLevel bulletListLevel1 = new NBulletListLevel();
// set the bullet type to text and bullet text to unicode char for filled bullet circle
bulletListLevel1.BulletType = ENBulletType.Text;
bulletListLevel1.BulletText = new string((char)0x25CF, 1);
bulletList.Levels.Add(bulletListLevel1);

 Note that the code above species a special char for the bullet text. The control provides the ENBulletChar enum which provides commonly used Unicode bullet chars:

ENBulletChar Description
None Empty bullet char. Unicode code point 0x0000.
BlackCircle Standard bullet char (disc, black circle). Unicode code point 0x25CF.
BlackTrianngle Triangular bullet char. Unicode code point 0x2023.
BlackSquare Filled square char. Unicode code point 0x25A0.
WhiteSquare White square char. Unicode code point 0x25A1.
WhiteCircle White circle char. Unicode code point 0x25CB.
Hyphen Hyphen bullet. Unicode code point 0x2043.
Asterisk Asterisk. Unicode code point 0x002A.

The following code snippet shows how to use the values in this enum:

Using Common Bullet Chars
Copy Code
bulletListLevel1.BulletText = new string((char)ENBulletChar.TriangularBullet, 1);

Bullet Tab Stop

The generated bullet text can optionally be followed by a space or tab character. This is controlled from the BulletFollowChar property accepting values from the ENBulletFollowChar enum:

ENBulletFollowChar Description
None No char follows the bullet.
Space The bullet is followed by space.
Tab The bullet is followed by tab. The tab stop can be controlled from the TabStop property of the list level.

 

Adding tabs that follow the bullets help to increase readability when the bullet list uses bullets embedded in paragraphs. The following code snippet shows how to create a bullet followed by a tab stop at 40 dips:

Adding Tab Stops After the Bullet
Copy Code
bulletListLevel1.BulletFollowChar = ENBulletFollowChar.Tab;
bulletListLevel1.TabStop = new NTabStop(40, ENTabStopAlignment.Left, ENTabStopLeaderStyle.None);


 

See Also
Send Feedback