Hi, I am very new to .net and C#. I have a datagridview that I want to print. I found the code below on the internet and adapted it to my project. It sends a blank page to the printer. Can someone tell me what is wrong? printDocument1 is declared in my class, dgvATC is the datagridview control I want to print.

private void print_Click(object sender, EventArgs e)
    {         
        printDocument1.Print();
    }

private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
    {
        Bitmap bm = new Bitmap(this.dgvATC.Width, this.dgvATC.Height);

        this.dgvATC.DrawToBitmap(bm, new Rectangle(0, 0, this.dgvATC.Width, this.dgvATC.Height));

        e.Graphics.DrawImage(bm, 0, 0);
    }

Thanks in advance for your help.
DaveD3

Recommended Answers

All 2 Replies

Does e.Graphics.DrawString("Hello world", aFont, aBrush, aPoint); work?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.