help printing

cerberus478

New member
Joined
Oct 8, 2011
Messages
1
Programming Experience
Beginner
Hi

I would like to know how to print information from my datagridview onto paper.

I know how to do it using text boxes which is like this
VB.NET:
e.Graphics.DrawString(txtTotal.Text, Plainfont, Brushes.Gray, right_column, vert)
vert = vert + 30

Is there something similar for a datagridview

Thank you
 
That code is not for a TextBox. DrawString simply draws a String. Where the String comes from is irrelevant. That code is using the Text property of a TextBox but it could come from anywhere, e.g. the Value of a DataGridView cell. Obviously, with a grid, there are lots of cells and the grid lines between them, so you have to make the appropriate calculations to determine what to print where. You could do those calculations yourself, but I know someone who has already done them.

DataGridPrinter - A class to print data grid in a nicely formatted way

The original class is for the old DataGrid control but there's an equivalent for the DataGridView later on.
 
Back
Top