views:

32

answers:

1

hi, i want send printDocument to second form to showing that in printPreviewControl which placed in second form.

form1 code

defined printDocument class with public access in form1

public System.Drawing.Printing.PrintDocument printDocument;

form2 code

private void Form2_Load(object sender, EventArgs e)
{
        Form1 form1 = new Form1;
        printPreviewControl.Document = form1.printDocument;
}

I am sure printDocument in form1 have document to print, but when form2 loaded nothing showed in printPreviewControl. what method of printDocument in form1 should be call before showing form2?

+1  A: 

Your example should work fine but the PrintPreviewControl will only render what it is fed during the PrintPage event that is attached to the PrintDocument.

If you aren't doing anything during the PrintPage event then the print preview will be a blank document.

Chances are that if you put to PrintPreviewControl on Form1 then you will recieve the same behavior.

Cory Charlton