Useful Form Printing
im searching the best way for Printing a whole form / Several Datagridview开发者_开发技巧s and some Specific controll contents in my WindowsForm application.
I know the internet is full with bad and good examples.
Its hard to separate the Good examples from the Bad examples.
So what can you reccomend me?
Whats your way to do this? Wich Examples in the Web are useful?
Thanks in advance
Try this code. This will print all the contents of the current form.
using (Bitmap bmp = new Bitmap(this.Width, this.Height))
{
this.DrawToBitmap(bmp, this.ClientRectangle);
using (PrintDocument p = new PrintDocument())
{
p.PrintPage += (o, pe) =>
{
pe.Graphics.DrawImage(bmp, this.ClientRectangle);
};
p.Print();
}
}
Sorry I didn't tested it.
you could create a snapshot from the form you want to print and then print the image.
For creating snapshots you could have a look here
精彩评论