user1870959
user1870959

Reputation:

WebBrowser Visual Basic

How do I stop a new tab from opening google.com automaticaly in visual basic. I need a blank url textbox This is my code for new tab

Private Sub AddTabToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles AddTabToolStripMenuItem.Click
    Dim tab As New TabPage
    Dim newtab As New tab
    newtab.Show()
    newtab.TopLevel = False
    newtab.Dock = DockStyle.Fill
    tab.Controls.Add(newtab)
    Form1.TabControl1.TabPages.Add(tab)
    Form1.TabControl1.SelectedTab = tab

And this is the code when form loads

Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim t As New TabPage
    Dim newtab As New tab
    newtab.Show()
    newtab.TopLevel = False
    newtab.Dock = DockStyle.Fill
    t.Controls.Add(newtab)
    TabControl1.TabPages.Add(t)

End Sub

Upvotes: 2

Views: 235

Answers (2)

sbowde4
sbowde4

Reputation: 777

If you wanted you could allow the user to set their own homepage.

Simply create a button, or an item in the drop down bar that says "Set Homepage"

Create a new setting for your web browser called homePage, set it to string. Do nothing else.

Next create a new form called Homepage and link it to the button you created in step one by double clicking the button and putting

homepage.show() 

in the code for that button.

On the other form you created you need a text box, and a button that says save.

double click the button and put this code in the button's code block.

textbox1.text = my.settings.homePage
my.settings.save()

Finally on your original browser form, under form1_load put this line of code

webbrowser1.navigate(my.settings.homePage)

That should work, it did for my browser at least

Upvotes: 1

sbowde4
sbowde4

Reputation: 777

It won't open a page until you actually set it to open a page. Somewhere in your code you have something that will look similar to

webbrowser1.navigate("www.google.com")

Most likely within your form_load event. Just delete that.

Upvotes: 0

Related Questions