I am fairly new to .NET and C#, but I have a DataGridView that I would like to print. What would be the best way to go about doing so?
This class includes codes to print Bill from data grid view in C# windows form application.
Add a DataGridView, a PrintDocuemnt, and a Button then:
button click events {
printDocument1.Print();
}
printDocument1_PrintPage events {
Bitmap bm = new Bitmap(this.dataGridView1.Width, this.dataGridView1.Height);
this.dataGridView1.DrawToBitmap(bm, new Rectangle(0, 0, this.dataGridView1.Width, this.dataGridView1.Height));
e.Graphics.DrawImage(bm, 0, 0);
}
That's all your data printing.
There are projects on CodeProject that have done some work printing DataGridViews.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With