tabbed webbrowser in vb.net
Posted by Unknown , Sunday, April 4, 2010 4:04 PM
Public Class Form1
002 | Dim URLString As String |
003 | Dim HomeURL As String = "www.bbc.com/football" |
004 | Dim i As Integer = 1 |
005 |
006 | 'This is our own module that causes the browser to naviagate to the link selected elsewhere |
007 | Private Sub GoToURL(ByVal SelectedURL As String) |
008 | wbBrowser.Navigate(SelectedURL) |
009 | If (cbWebsite.FindStringExact(URLString) < 0) And (URLString <> Nothing) Then |
010 | ' if not already in list - add this url to the combobox |
011 | cbWebsite.Items.Add(URLString) |
012 | End If |
013 | End Sub |
014 | Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load |
015 |
016 | End Sub |
017 | Private Sub lblWebsite_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) |
018 |
019 | End Sub |
020 |
021 | Private Sub btnWebsite_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click |
022 | If cbWebsite.SelectedItem = "" Then |
023 | URLString = cbWebsite.Text |
024 | Else |
025 | URLString = cbWebsite.SelectedItem |
026 | End If |
027 | GoToURL(URLString) |
028 | End Sub |
029 | Private Sub txtURL_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cbWebsite.KeyDown |
030 | If e.KeyData = Keys.Enter Then ' Instead of pressing GO, it will accept enter on the keyboard ' |
031 | btnGo.PerformClick() |
032 | e.SuppressKeyPress = True |
033 | End If |
034 | End Sub |
035 |
036 | Private Sub btnBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click |
037 | WbBrowser.GoBack() |
038 | End Sub |
039 |
040 | Private Sub btnHome_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton5.Click |
041 | GoToURL(HomeURL) |
042 | End Sub |
043 |
044 | Private Sub btnForward_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click |
045 | WbBrowser.GoForward() |
046 | End Sub |
047 |
048 | Private Sub btnGoogle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GoogleToolStripMenuItem.Click |
049 | URLString = "http://www.google.co.uk/search?hl=en&q=" & tbSearch.Text |
050 | GoToURL(URLString) |
051 |
052 | End Sub |
053 |
054 | Private Sub btnMsn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MsnToolStripMenuItem.Click |
055 | URLString = "http://search.msn.co.uk/results.aspx?q=" & tbSearch.Text |
056 | GoToURL(URLString) |
057 |
058 | End Sub |
059 |
060 | Private Sub btnAskJeeves_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AskJeevesToolStripMenuItem.Click |
061 | URLString = "http://uk.ask.com/web?q=" & tbSearch.Text |
062 | GoToURL(URLString) |
063 |
064 | End Sub |
065 |
066 | Private Sub WbBrowser_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WbBrowser.DocumentCompleted |
067 | lblwebpage.Text = WbBrowser.Url.ToString |
068 |
069 | End Sub |
070 |
071 | Private Sub StatusStrip1_ItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles StatusStrip1.ItemClicked |
072 |
073 | End Sub |
074 |
075 | Private Sub WbBrowser_ProgressChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs) Handles WbBrowser.ProgressChanged |
076 | prgdownload.Value = (e.CurrentProgress / e.MaximumProgress) * 100 |
077 |
078 | End Sub |
079 |
080 | Private Sub btnRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click |
081 | WbBrowser.Refresh() |
082 | End Sub |
083 |
084 | Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton4.Click |
085 | WbBrowser.Stop() |
086 | End Sub |
087 |
088 | Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click |
089 | Dim Browse As New WebBrowser |
090 | TabControl1.TabPages.Add(1, "Page" & i) |
091 | TabControl1.SelectTab(1 - 1) |
092 | Browse.Name = "WbBrowser" |
093 | Browse.Dock = DockStyle.Fill |
094 | TabControl1.SelectedTab.Controls.Add(Browse) |
095 | i = i + 1 |
096 | End Sub |
097 |
098 | Private Sub btnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.Click |
099 | TabControl1.TabPages.RemoveAt(TabControl1.SelectedIndex) |
100 | TabControl1.SelectTab(TabControl1.TabPages.Count - 1) |
101 | i = i - 1 |
102 | End Sub |
103 | End Class |
Post a Comment