How to print row numbers in RadPrintDocument
Environment
Product Version | Product | Author |
---|---|---|
2021.2.511 | RadGridView for WinForms | Nadya Karaivanova |
Description
A client's requirement is to display row numbers in front of each row in RadGridView. This can be easily achieved in ViewCellFormatting event where you can sync the e.CellElement.Text to display the respective CellElement.RowIndex. However, when printing the grid using RadPrintDocument, this column is not automatically printed.
This tutorial will demonstrate how you can print the most left column in RadGridView containing row numbers.
Solution
Let's first set up our grid to display row numbers at the beginning of each row:
Then, to print this column in the RadPrintDocument it is neccessary to handle the PrintCellPaint event and paint the necessary info. This event allow you to access the cell and to paint in it whatever you need.
Thus, when printing the grid via the PrintButton_Click you should see the printed row numbers in the document: