我的项目中的datagridView没有完全打印

时间:2017-08-10 20:16:29

标签: c# printing datagridview

我要打印的dataGridView

img

当我打印时,输出中缺少某些列

private void btnPrint_Click(object sender, EventArgs e)
{
    int height = dataGridView1.Height;
    // int width = dataGridView1.Width;
    dataGridView1.Height = dataGridView1.RowCount * dataGridView1.RowTemplate.Height * 2;
    map = new Bitmap(this.dataGridView1.Width,this.dataGridView1.Height);
    dataGridView1.DrawToBitmap(map, new Rectangle(0,0,this.dataGridView1.Width, this.dataGridView1.Height));
    dataGridView1.Height = height;
    printPreviewDialog1.Document = printDocument1;
    printPreviewDialog1.PrintPreviewControl.Zoom = 1;
    printPreviewDialog1.ShowDialog();
}

private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
    e.Graphics.DrawImage(map,0, 0);
}

0 个答案:

没有答案