Im trying to make tabbed webrowser with history and bookmarks.
But when i press f5, it works, but when i try to add new tab it crashes
heres code:
Public Class Form1
Dim int As Integer = 0
Private Sub Loading(ByVal sender As Object, ByVal e As Windows.Forms.WebBrowserProgressChangedEventArgs)
ToolStripProgressBar1.Maximum = e.MaximumProgress
ToolStripProgressBar1.Value = e.CurrentProgress
End Sub
Private Sub Done(ByVal sender As Object, ByVal e As Windows.Forms.WebBrowserDocumentCompletedEventArgs)
TabControl1.SelectedTab.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).DocumentTitle
ComboBox1.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.ToString
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Browser As New WebBrowser
TabControl1.TabPages.Add("New Page")
Browser.Name = "Expree™ Browser"
Browser.Dock = DockStyle.Fill
TabControl1.SelectedTab.Controls.Add(Browser)
AddHandler Browser.ProgressChanged, AddressOf Loading
AddHandler Browser.DocumentCompleted, AddressOf Done
int = int + 1
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoHome()
For Each item As String In My.Settings.History
ComboBox1.Items.Add(item)
Next
For Each item As String In My.Settings.Bookmarks
BookmarksToolStripMenuItem.DropDownItems.Add(item)
Next
End Sub
Private Sub NewTabToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim Browser As New WebBrowser
TabControl1.TabPages.Add("New Page")
TabControl1.SelectTab(int)
Browser.Name = "Expree™ Browser"
Browser.Dock = DockStyle.Fill
TabControl1.SelectedTab.Controls.Add(Browser)
AddHandler Browser.ProgressChanged, AddressOf Loading
AddHandler Browser.DocumentCompleted, AddressOf Done
int = int + 1
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoHome()
End Sub
Private Sub RemoveTabToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
If Not TabControl1.TabPages.Count = 1 Then
TabControl1.TabPages.RemoveAt(TabControl1.SelectedIndex)
TabControl1.SelectTab(TabControl1.TabPages.Count - 1)
int = int - 1
End If
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(ComboBox1.Text)
End Sub
Private Sub NewWindowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub RemoveWindowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RemoveWindowToolStripMenuItem.Click
Me.Close()
End Sub
Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub WebsitePropertiesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WebsitePropertiesToolStripMenuItem.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ShowPropertiesDialog()
End Sub
Private Sub PageSourceToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub TabControl1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
ComboBox1.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.ToString()
End Sub
Private Sub RadioButton6_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton6.CheckedChanged
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.ToString()
End Sub
Private Sub YoutubeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://www.youtube.com")
End Sub
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoBack()
End Sub
Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoForward()
End Sub
Private Sub PictureBox3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox3.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Stop()
End Sub
Private Sub PictureBox4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox4.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Refresh()
End Sub
Private Sub PictureBox5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox5.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoHome()
End Sub
Private Sub PictureBox6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox6.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(ComboBox1.Text)
My.Settings.History.Add(ComboBox1.Text)
ComboBox1.Items.Add(ComboBox1.Text)
End Sub
Private Sub PictureBox7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox7.Click
If Not TabControl1.TabPages.Count = 1 Then
TabControl1.TabPages.RemoveAt(TabControl1.SelectedIndex)
TabControl1.SelectTab(TabControl1.TabPages.Count - 1)
int = int - 1
End If
End Sub
Private Sub PictureBox8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox8.Click
Dim Browser As New WebBrowser
TabControl1.TabPages.Add("New Page")
TabControl1.SelectTab(int)
Browser.Name = "Expree™ Browser"
Browser.Dock = DockStyle.Fill
TabControl1.SelectedTab.Controls.Add(Browser)
AddHandler Browser.ProgressChanged, AddressOf Loading
AddHandler Browser.DocumentCompleted, AddressOf Done
int = int + 1
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoHome()
End Sub
Private Sub PictureBox9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox9.Click
If RadioButton2.Checked Then
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://www.google.fi/search?hl=en&q=" & ComboBox2.Text & "&btnG=Google+Search&meta=")
End If
If RadioButton3.Checked Then
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://www.bing.com/search?q=" & ComboBox2.Text & "&fr=yfp-t-501&toggle=1&cop=mss&ei=UTF-8&fp_ip=IN&vc=")
End If
If RadioButton1.Checked Then
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://www.youtube.com/results?search_query=" & ComboBox2.Text & "&search_type=&aq=-1&oq=")
End If
If RadioButton7.Checked Then
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://search.yahoo.com/search?p=" & ComboBox2.Text & "&vc=&fr=yfp-t-150&toggle=1&cop=mss&ei=UTF-8&fp_ip=FI")
End If
If RadioButton4.Checked Then
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://fi.wikipedia.org/wiki/" & ComboBox2.Text & "")
End If
If RadioButton5.Checked Then
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://www.yebol.com/newsearch?key=" & ComboBox2.Text & "&t=s&x=0&y=0")
End If
If RadioButton8.Checked Then
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://duckduckgo.com/?q=" & ComboBox2.Text & "&v=")
End If
If RadioButton6.Checked Then
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://hiki.pedia.ws/wiki/" & ComboBox2.Text & "")
End If
If RadioButton9.Checked Then
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://www.altavista.com/web/results?itag=ody&q=" & ComboBox2.Text & "&kgs=1&kls=0")
End If
If RadioButton10.Checked Then
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://search.microsoft.com/results.aspx?qsc0=0&q=" & ComboBox2.Text & "&x=0&y=0&mkt=en-US&FORM=QBME1&l=1")
End If
If RadioButton11.Checked Then
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://www.cuil.com/search?q=" & ComboBox2.Text & "")
End If
If RadioButton12.Checked Then
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://www.ask.com/web?q=" & ComboBox2.Text & "&search=search&qsrc=0&o=0&l=dir")
End If
If RadioButton13.Checked Then
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://www.alltheweb.com/search?cat=web&cs=iso88591&q=" & ComboBox2.Text & "&rys=0&itag=crv&_sb_lang=pref")
End If
If RadioButton14.Checked Then
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://fi.altavista.com/web/results?itag=ody&q=" & ComboBox2.Text & "&kgs=1&kls=0")
End If
End Sub
Private Sub RadioButton11_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton11.CheckedChanged
End Sub
Private Sub RadioButton14_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton14.CheckedChanged
End Sub
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
For Each item As String In My.Settings.History
ComboBox1.Items.Add(item)
Next
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If ComboBox1.Text = "Clear All History" Then
My.Settings.History.Clear()
End If
If ComboBox1.Text = "Clear All History" Then
ComboBox1.Items.Clear()
End If
End Sub
Private Sub AddBookmarkToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddBookmarkToolStripMenuItem.Click
ToolStripTextBox1.Text = ComboBox1.Text()
End Sub
Private Sub AddToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddToolStripMenuItem.Click
My.Settings.Bookmarks.Add(ToolStripTextBox1.Text)
BookmarksToolStripMenuItem.DropDownItems.Add(ToolStripTextBox1.Text)
My.Settings.Save()
End Sub
End Class