First, the data is not IN a DataGridView Control. The DataGridView Control
is a UI element for displaying the data. The data itself is in the
underlying data source that the DataGridView Control is bound to.
Second, printing is basically the process of creating an image and drawing
(or "painting" if you will) the image to a printer. This is essentially done
using the classes of the System.Drawing.Printing namespace, and most
specifically using the PrintDocument class, along with the PrinterSettings
and PageSettings classes. Here is the online documentation for all of them:
http://msdn2.microsoft.com/en-us/lib...ng(VS.71).aspx
These classes handle communications with the various Printer drivers on the
machine, providing a single programming interface to work with.
So, in order to print the data you want, which is tabular in nature, you
have to go through it row by row, column by column, format it for printing
however you wish, and create as many pages of images of the data as
necessary by "painting" the data to the System.Drawing.Graphics instance
that is provided with the PrintPageEventArgs instance that is provided by
each PrintPage event raised by the PrintDocument class. This means that it
is necessary to measure the height and width of the data as you go, so that
each page image will not exceed the boundaries of the printable area of the
page. Your code will determine the number of times that the event is raised
to print each page necessary.
That's it in a nutshell. The documentation should provide the rest of the
solution.
--
HTH,
Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com
The shortest distance between 2 points is a curve.
"Chris" <Ch***@discussions.microsoft.comwrote in message
news:B2**********************************@microsof t.com...
Any tips on how to print the data in a datagridview control?