Skip to content

Enable the line numbering and implement the LayoutVisitor to count rows in a document.

License

Notifications You must be signed in to change notification settings

DevExpress-Examples/winforms-richedit-enable-line-numbering-and-count-document-rows

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rich Text Editor for WinForms - How to Enable Line Numbering and Count Document Rows

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.

image

Implementation Details

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.

Files to Review

Documentation

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)