tak_juju

I have created a webbrowser and and dialog box. When the dialog box appears there is a text box and a set button, i want this button to set my webbrowser hompage when i type the url in textbox.



Re: Visual Basic Express Edition How to set webbrowser homepage?

djshades2004

Why not save the homepage in your settings file

and when you want to update the your new site,

my.mysettings.homepage = "google.co.uk"

this would be the easiest way.





Re: Visual Basic Express Edition How to set webbrowser homepage?

tak_juju

this doest work dude





Re: Visual Basic Express Edition How to set webbrowser homepage?

djshades2004

you have to create the setting.

goto project then application settings.

click on settings tab, then create a new setting. eg "homepage"

then in your form load event point the webbrowser navigate to the setting value.





Re: Visual Basic Express Edition How to set webbrowser homepage?

tak_juju

Sorry but this is not helping me, im new. Can you please! explain me in detail





Re: Visual Basic Express Edition How to set webbrowser homepage?

Martin Xie - MSFT

Hi tak_juju,

Djshades came up with a good idea.

1. In Solution Explorer, right-click your project

2. Click the "Properties" context menu item

3. In Settings tab, add a new setting(e.g. Name: homepage TypeTongue Tiedtring Scope:User Value:google.co.uk)

4. Add the following code in the Form_Load event.

Code Snippet

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

WebBrowser1.Navigate(My.Settings.homepage)

End Sub

If you intend to achieve the goal as your original idea, the solution as below.

Form1 contains a WebBrowser1 control and a Button1 control.

Form2 contains a TextBox1 control and a Button1 control.

Click Form1's Button1 to open Form2 as a modal dialog

Code Snippet

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim frm As Form2 = New Form2()

frm.ShowDialog()

End Sub

Then input URL to TextBox1 and click Form2's Button1 to set homepage for WebBrowser1.

Code Snippet

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim frm As Form1 = New Form1()

frm.WebBrowser1.Navigate(TextBox1.Text.ToString())

frm.WebBrowser1.Refresh()

frm.Show()

Me.Hide()

End Sub

I hope that can help you.

Best regards,

Martin Xie