Click here to Skip to main content
15,998,673 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have to print Complete datagrid values but my code is printing something equivalent to screenshot

What I have tried:

C#
PrintDialog printDlg = new PrintDialog();
if (printDlg.ShowDialog() == true)
{
    printDlg.PrintVisual(DatagridView, "My Report");
}




i need complete data to print when we save it
Posted
Updated 18-Feb-19 21:56pm
v2

1 solution

First off, don't print a DataGridView: that's a control, not the data it contains, and it only usually displays a small subset of the data, not the whole thing. It can also be filtered via a view to show less data than it "should".

Instead print the data content, by either using the underlying DataSource or the Rows from the DGV itself.
Then manually use DrawString to add them to your output - which lets you determine how much "fits" on a page, which printing the DGV can't as it is only a small "snapshot" of the currently visible data.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900