2010-09-16 74 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