This example enables line numbering for the first document section. 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 75 documents (0.25 of an inch).
The Custom Draw technique is used to display the line number column with a color background.
The Section.LineNumbering property enables line numbering for the first document section.
Set the AllowDisplayLineNumbers property to true
in the SimpleView and DraftView views to display line numbering. To make line numbers visible, the left padding is increased to 60
points.
The Line Number document style defines the used font and color.
Create a custom PagePainter descendant which implements the methods required to draw the column background and the line numbers. Handle the RichEditControl.BeforePagePaint event and set the BeforePagePaintEventArgs.Painter property to the PagePainter
descendant instance.
Create an instance of the LayoutVisitor descendant and let it traverse the page layout. When it encounters a new row, it calls the VisitRow
method. This method increments the row counter to count the lines on a page. To run the visitor each time after building the document layout, handle the DocumentLayout.DocumentFormatted event.
- Form1.cs (VB: Form1.vb)
- MyLayoutVisitor.cs (VB: MyLayoutVisitor.vb)
- MyPagePainter.cs (VB: MyPagePainter.vb)
(you will be redirected to DevExpress.com to submit your response)