Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How To: Add Line Numbering

The following example illustrates how to adjust line numbering to the specified document section.

To enable Line Numbering, set the RichEditView.AllowDisplayLineNumbers option for the current view to true and specify the SectionLineNumbering.CountBy property to a non-zero positive value.

In SimpleView and DraftView views line numbers are outside the default visible area, so you have to provide a space to display them by setting the left padding to a higher value (use the SimpleView.Padding or the DraftView.Padding property, respectively).

The line numbering font face and font color are specified by the Line Number character style.

To specify line numbering, the following properties are provided:

All the line numbering parameters can be accessed through the Section.LineNumbering property.

View Example

document.LoadDocument("Documents//Grimm.docx", DevExpress.XtraRichEdit.DocumentFormat.OpenXml);
document.Unit = DevExpress.Office.DocumentUnit.Inch;
Section sec = document.Sections[0];
sec.LineNumbering.CountBy = 2;
sec.LineNumbering.Start = 1;
sec.LineNumbering.Distance = 0.25f;
sec.LineNumbering.RestartType = LineNumberingRestart.NewSection;