2010-09-16 36 views
1

我使用WebBrowser打印一些HTML數據,除了在加載完成事件中調用的打印預覽之外,所有工作都很好 - 它作爲左上角的一個非常小的窗口打開,任何I可以這樣做來改善嗎?WebBrowser ShowPrintPreviewDialog()非常小

Private Sub BtnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnPrint.Click 
    Dim webBrowserForPrinting As New WebBrowser() 
    AddHandler webBrowserForPrinting.DocumentCompleted, New WebBrowserDocumentCompletedEventHandler(AddressOf PrintDocument) 
    webBrowserForPrinting.DocumentText = HTMLTEST() 
End Sub 

Private Sub PrintDocument(ByVal sender As Object, ByVal e As WebBrowserDocumentCompletedEventArgs) 
    Dim webBrowserForPrinting As WebBrowser = CType(sender, WebBrowser) 
    webBrowserForPrinting.ShowPrintPreviewDialog() 
End Sub 

回答

7

嘗試將webBrowserForPrinting對象的Parent屬性設置爲Me。

webBrowserForPrinting.Parent = Me 
+0

啊啊那是一個 - 謝謝! – madlan 2010-09-16 23:39:32

+0

+1救了我幾個小時的搜索,非常感謝 – smirkingman 2013-07-17 08:51:17