WebBrowser control how to print?

muddser

New member
Joined
Oct 9, 2010
Messages
3
Programming Experience
Beginner
Hiii allll!!!

I have just started using vb 2008...

I have created a web browser by using it...

now all I want from this is tht I want to make it able to print & show print preview of any webpage which I'm browsing..
I've been searching for it since last 3 days...

It's really driving me crazy...

Please help me anyone... if u can...

Thanks in advance...
 
To print call the Print method, to printpreview call the ShowPrintPreviewDialog method.
Here is the online help page for this class: WebBrowser Class (System.Windows.Forms)
If you in navigation tree select the Methods node, then in top menu deselect Inherited and Protected members you will see this class has just a few publicly available implemented methods, and the two mentioned are among these. Sometimes that is not the case though, and the member you're looking for may be inherited from a base class, so you may have to look through a longer list of members to find it, but anyway you should learn to use and look in the help documentation first.
 
thnax very nuch sir...

sir... I've done it with ur help frm viewin tht microsoft website for which u gave me d link...

thnx very much....

it'll b more good if I can format the dialog boxes so tht they can look like othr than IE..

if u can then gimme suggestion for this also...

thanx..
 
Hi if it is not answered
I just added with or without a Menustrip on my browser and then put this code in


For the Print

Private Sub PrintToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintToolStripMenuItem.Click
WebBrowser1.ShowPrintDialog()
End Sub

For the Print preview


Private Sub PrintPreviewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintPreviewToolStripMenuItem.Click
WebBrowser1.ShowPrintPreviewDialog()
End Sub

With buttons instead

for print

Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click

WebBrowser1.ShowPrintDialog()
End Sub

For print preview

Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click

WebBrowser1.ShowPrintPreviewDialog()
End Sub
 
Last edited:
on button click

just add Webbrower1.print() as shown:

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
WebBrowser1.Print()
End Sub
 
Back
Top