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

Edited 3 Years Ago by Reverend Jim: Fixed formatting

This question has already been answered. Start a new discussion instead.