Hello Respected members
I have problam
How to write code for print datagridview with print preview option in c# in window application
I have code for print but its directly print document not Previewing document that why the i am not able to print all datagridview item
Can any body help me for sort out my problam
private void button1_Click(object sender, EventArgs e)
{
try
{
printDocument1.Print();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
Bitmap dataGridViewImage=new Bitmap(this.dataGridView1.Width,this.dataGridView1.Height);
dataGridView1.DrawToBitmap(dataGridViewImage, new Rectangle(0, 0, this.dataGridView1.Width, this.dataGridView1.Height));
e.Graphics.DrawImage(dataGridViewImage, 0, 0);
}
Thans in Advance
Good luck :)