this is going to be very good , i will teach you to make a advanced web browser in vb.net . just create a new project
add a webbrowser and set the webbrowser behind the form
now add this codes i mean just erase everything and add this
drag and drop 7 buttons from the toolbox and change the text property as below
button1-back
button2-forward
button3-refresh
button4-stop
button5-go
button6-add tab
button7-close tab
add a textbox
now add a tabcontrol from toolbox and delete all the tabpages(tabpage1>tabpage2))
like this
add a webbrowser and set the webbrowser behind the form
now add this codes i mean just erase everything and add this
Public Class Form1 'Author : Mohamed Shimran 'Blog : http://www.ultimateprogrammingtutorials.blogspot.com Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try Dim tab As New TabPage Dim brws As New WebBrowser brws.Dock = DockStyle.Fill tab.Text = " New Tab" tab.Controls.Add(brws) Me.TabControl1.TabPages.Add(tab) Me.TabControl1.SelectedTab = tab brws.Navigate("") Catch ex As Exception End Try End Sub Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click Try Dim tab As New TabPage Dim brws As New WebBrowser brws.Dock = DockStyle.Fill tab.Text = "New Tab" tab.Controls.Add(brws) Me.TabControl1.TabPages.Add(tab) Me.TabControl1.SelectedTab = tab brws.Navigate("") Catch ex As Exception End Try End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoBack() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoForward() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Refresh() End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click Try CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(TextBox1.Text) Catch ex As Exception End Try End Sub Private Sub TabPage2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) End Sub Private Sub TabPage1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) End Sub Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click TabControl1.Controls.Remove(TabControl1.SelectedTab) End Sub Private Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Stop() End Sub End Class
10 comments
Thanks for post it is so useful :) ,but how can I create methods such as webbrowser doc.completed for an uncreated webBrowser ? I tried to replace webbrowser1 with CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser)
Replybut it is not working.
Hi,
ReplyI have no idea about "uncreated web browser" :-? , could you please explain ?
Line 9 & 27, its says at me Type expected (For webbrowser)
ReplyFound it, replaced
ReplyWebbrowser
with
Windows.Forms.WebBrowser
Thanx very usefull post for me...!
ReplyI will explain. When you run The prgram you have web browser. But acctually, methods wants this webbrowser to be in the designer.
ReplyThanks dude!
Replywhy use Span in this code ?
Replyany one can talk me about this topic ?
thx
ReplyPost a Comment
Note: Only a member of this blog may post a comment.