PrintDocument and the Graphics Object
So as I earlier said we need to actually draw all including text using the Graphics object. The print document needs to be prepared before actual printing starts. So we can use the event PrintPage, in this event we can draw all the objects as we need.Draw the DataGridView like a table using lines
To get a tabular data to represent the DataGridView, we need to do the following• Draw an outer rectangle as the border to table
• Draw a line for every row
• Draw a line for every column while iterating the cell
• Draw the cell value as text
All the above said items can be drawn with the help of the DataGridView’s native properties, Left, Top, Height, Width, Row.Hieght, and Column. Width
Refer source code VB.Net Print Datagridview in WinForms
0 comments:
Post a Comment