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
有帮助吗?

解决方案

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();
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top