Click here to Skip to main content
14,927,597 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Print 5 dataGridViews in one time in one sheet

What I have tried:

Well , please look at the code below:

I tried this code, it works, but it prints one DataGridView at a time :

C#
private void printTest_Click(object sender, EventArgs e)
{
    DGVPrinter printer = new DGVPrinter();
    printer.Title = "";
    printer.SubTitle = "";
    printer.SubTitleFormatFlags = StringFormatFlags.LineLimit |
            StringFormatFlags.NoClip;
    printer.PageNumbers = true;
    printer.PageNumberInHeader = false;
    printer.PorportionalColumns = true;
    printer.HeaderCellAlignment = StringAlignment.Near;
    printer.Footer = "  ";
    printer.FooterSpacing = 15;

    printer.PrintDataGridView(datagridview1);
}
The problem is that if you add these pieces of code, it opens the print window each time, for each of these operations.

printer.PrintDataGridView (datagridview2); // new print windows
printer.PrintDataGridView (datagridview3); // new print windows
printer.PrintDataGridView (datagridview4); // new print windows
printer.PrintDataGridView (datagridview5); // new print windows


If I wanted to use all 5 DataGrridView at the same time and on the same page, and just a print window. What should I do ??
Posted
Updated 8-Feb-19 5:19am
v6
Comments
Richard MacCutchan 8-Feb-19 11:48am
   
You cannot make 5 different method calls and expect it to understand that you want to merge the 5 grids.
__Ivan 8-Feb-19 12:01pm
   
OK, WELL..how can i solve it ?:)
Richard MacCutchan 8-Feb-19 12:14pm
   
Go and ask the person who wrote the article. Or modify the code yourself.
__Ivan 8-Feb-19 12:15pm
   
if I write here and why I need help, and you're not helpful, what are your answers for?
Richard MacCutchan 8-Feb-19 12:25pm
   
I am trying to be helpful by telling you where you need to go to find help on this issue. As OriginalGriff has already pointed out, this class came from an article here on CodeProject, so you need to go there for help. The rest of us have no knowledge of what it is supposed to do or how it does it.

But I would also remind you of my earlier comment, "You cannot make 5 different method calls and expect it to understand that you want to merge the 5 grids.".
__Ivan 8-Feb-19 12:29pm
   
now you have explained yourself, I thank you.

1 solution

Quote:
What should I do?

Start by realising there are 13,852,767 members here that you could be talking to, and only one that is relevant. So posting a question in general forum like this and just saying
Quote:
I tried your solution, but it does not fit my needs.
Doesn't tell anyone what "solution" you are referring, or who actually wrote it and has been corresponding with you about it.

Don't post this under Quick Answers - if you got the code from an article, then there is a "Add a Comment or Question" button at the bottom of that article, which causes an email to be sent to the author. They are then alerted that you wish to speak to them.
Posting this here relies on them "dropping by" and realising it is for them.
   
v2

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