Skip to main content

ListLevel Interface

Represent a list level in a numbered or bulleted list.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v24.1.Core.dll

NuGet Packages: DevExpress.RichEdit.Core, DevExpress.Win.Navigation

Declaration

[ComVisible(true)]
public interface ListLevel :
    ListLevelProperties

Remarks

Use the NumberingList.Levels or NumberingListBase.Levels property to access list levels for a particular list.

The ListLevelProperties.NumberingFormat and ListLevelProperties.DisplayFormatString properties allow you to define a numbering style and a format for the level mark.

You can specify character and paragraph format for a level marker using the ListLevel.CharacterProperties or ListLevel.ParagraphProperties properties.

The following code snippet illustrates how to specify list level properties for a multilevel list.

View Example

Document document = server.Document;

document.BeginUpdate();

//Create a new pattern object
AbstractNumberingList abstractListNumberingRoman = document.AbstractNumberingLists.Add();

//Specify the list's type
abstractListNumberingRoman.NumberingType = NumberingType.Simple;

//Define the first level's properties
ListLevel level = abstractListNumberingRoman.Levels[0];
level.ParagraphProperties.LeftIndent = 150;

// Align list with the surrounding text
level.ParagraphProperties.FirstLineIndentType = ParagraphFirstLineIndent.Hanging;
level.ParagraphProperties.FirstLineIndent = 75;
level.Start = 1;

//Specify the roman format
level.NumberingFormat = NumberingFormat.LowerRoman;
level.DisplayFormatString = "{0}.";

//Create a new list based on the specific pattern
NumberingList numberingList = document.NumberingLists.Add(0);

document.EndUpdate();

document.BeginUpdate();
ParagraphCollection paragraphs = document.Paragraphs;
//Add paragraphs to the list
paragraphs.AddParagraphsToList(document.Range, numberingList, 0);
document.EndUpdate();

You can change the starting number of the list level. Call the OverrideListLevel.SetOverrideStart method and specify a new start number as a OverrideListLevel.NewStart property value.

document.BeginUpdate();
// Define an abstract list that is the pattern for lists used in the document.
AbstractNumberingList list = document.AbstractNumberingLists.Add();
list.NumberingType = NumberingType.Simple;

ListLevel level = list.Levels[0];
level.Start = 1;
level.NumberingFormat = NumberingFormat.UpperRoman;
level.DisplayFormatString = "{0}.";

// Create a list for use in the document. It is based on a previously defined abstract list with ID = 0.
NumberingList bulletedList = document.NumberingLists.Add(0);
NumberingList overrideList = document.NumberingLists.Add(0);

overrideList.Levels[0].SetOverrideStart(true);
overrideList.Levels[0].NewStart = 3;
document.EndUpdate();

DocumentRange range = document.CreateRange(document.Paragraphs[0].Range.Start,document.Paragraphs[3].Range.End.ToInt() - document.Paragraphs[0].Range.Start.ToInt());
document.Paragraphs.AddParagraphsToList(range, bulletedList,0);

DocumentRange range2 = document.CreateRange(document.Paragraphs[5].Range.Start, document.Paragraphs[7].Range.End.ToInt() - document.Paragraphs[4].Range.Start.ToInt());
document.Paragraphs.AddParagraphsToList(range2, overrideList, 0);
See Also