How To Make A Tabbed WebBrowser In VB.NET

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


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


preview of this program :

11 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)
but it is not working.

Reply

Hi,

I have no idea about "uncreated web browser" :-? , could you please explain ?

Reply

Line 9 & 27, its says at me Type expected (For webbrowser)

Reply

Found it, replaced

Webbrowser

with

Windows.Forms.WebBrowser

Reply

Thanx very usefull post for me...!

Reply
This comment has been removed by the author.

I will explain. When you run The prgram you have web browser. But acctually, methods wants this webbrowser to be in the designer.

Reply

why use Span in this code ?
any one can talk me about this topic ?

Reply

CIITN is the best SAP training and placement Institute in noida. Contestant will analyze in keeping with modern-day enterprise trends by way of certified and industry experts & SAP training Institute in Noida. They provide a 100% placement help with the best training of IT cousrses.

If you are looking best sap training in Noida then you can join CIITN. One of the premier training and development institute for SAP Training Program in Noida. The company provides 6 weeks/ 6 Months Training for SAP. They provide training in all SAP Modules like SAP HANA,SAP B1, SAP FICO etc. Just come for free demo class and then join SAP and move up in your career .

SAP Training Institute in Noida
sap training in noida
sap institute in noida
sap course in noida
best sap training institute in noida

Reply

Post a Comment