0

im searching the best way for Printing a whole form / Several Datagridviews 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

Brad Werth
  • 17,411
  • 10
  • 63
  • 88
SwissGuy
  • 565
  • 1
  • 6
  • 18
  • There are only bad ways to print a form. The resolution of a printer is far too high, the form turns into a blocky and grainy mess that only looks good from 10 feet. Use PrintDocument to print output that looks nice and razor-sharp on a piece of paper. Easily takes care of printing grids that have too many rows as well. – Hans Passant Mar 03 '11 at 13:31

2 Answers2

0

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.

Anuraj
  • 18,859
  • 7
  • 53
  • 79
0

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

Community
  • 1
  • 1
Dirk Trilsbeek
  • 5,873
  • 2
  • 25
  • 23
  • Thanks for you answer, ive already tried something familiar, what can you say to the Quality? In my test, the output quality was terrible and doesnt fit to our needs – SwissGuy Mar 03 '11 at 10:16
  • i believe the quality would depend on your printing method, the image itself should be a 1:1 capture without any quality loss. To make sure the image quality is ok you could save the screenshot to disk so you can have a look at the created image itself. Possibly the bad quality results from image scaling when you print the image. – Dirk Trilsbeek Mar 03 '11 at 10:46