Question

i copied and pasted the code from msdn, i don't know what is 'PrintDocument' in that line:

webBrowserForPrinting.DocumentCompleted +=
        new WebBrowserDocumentCompletedEventHandler(PrintDocument);

i change it to 'printDocument1' but it tells me :

printDocument1 is a 'field' but is used like a 'method'

in my form :

 - printPreviewControl1
 - printDocument1
 - pageSetupDialog1
Was it helpful?

Solution

You need to also include the PrintDocument() method from that sample:

private void PrintDocument(object sender,
    WebBrowserDocumentCompletedEventArgs e)
{
    // Print the document now that it is fully loaded.
    ((WebBrowser)sender).Print();

    // Dispose the WebBrowser now that the task is complete. 
    ((WebBrowser)sender).Dispose();
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top