Skip to main content

Line Numbering

  • 2 minutes to read

DXRichEdit_LineNummbering

To switch line numbering on, specify the SectionLineNumbering.CountBy property to any non-zero positive integer value. Other line numbering parameters for a certain section can be set up as illustrated in the code snippet below.

The following code snippet enables line numbering for the first section in the loaded document. Line numbering starts at number one and restarts at the new section. Numbers are displayed on each second line and are indented from the text at a distance equal to 0.25 of an inch.

using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;
// ...
private void richEditControl1_DocumentLoaded(object sender, EventArgs e) {
    richEditControl1.Document.Unit = DocumentUnit.Inch;
    Section sec = richEditControl1.Document.Sections[0];
    sec.LineNumbering.CountBy = 2;
    sec.LineNumbering.Start = 1;
    sec.LineNumbering.Distance = 0.25F;
    sec.LineNumbering.RestartType = LineNumberingRestart.NewSection;
}

You can also invoke the Line Numbers Dialog.

NOTE

The RichEditView.AllowDisplayLineNumbers enables you to show or hide line numbers in a view.

See Also