How To: Add Line Numbering
- 2 minutes to read
The following example illustrates how to adjust line numbering to the specified document section.
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:
- SectionLineNumbering.Start - sets the starting line number;
- SectionLineNumbering.Distance - sets the distance between the line number and the start of the line;
- SectionLineNumbering.RestartType - sets when the line numbering should be reset to the starting line number;
All the line numbering parameters can be accessed through the Section.LineNumbering property.
Document document = server.Document; document.LoadDocument("Documents\\Grimm.docx", DevExpress.XtraRichEdit.DocumentFormat.OpenXml); document.Unit = DevExpress.Office.DocumentUnit.Inch; Section sec = document.Sections; sec.LineNumbering.CountBy = 2; sec.LineNumbering.Start = 1; sec.LineNumbering.Distance = 0.25f; sec.LineNumbering.RestartType = LineNumberingRestart.NewSection;