Web Browser
Posted: Mon Sep 19, 2011 11:56 pm
This tutorial will show you how to make a web browser;
1 Click on Project next to Create:
2 Click on Windows Form Application, and name the project "Your name's Application" and then click Ok.
You can change the form text to "your name's web browser". Click on the form and then go to properties window, then change the text property.
In the properties window, change the WindowState property to Maximized so that when the user launch the web browser, it will be maximized:
3 Add a Webbrowser from the toolbox.
Change the dock property
4 Right click on the webbrowser and click on properties. In the properties window change the Anchor property to Top, Bottom, Left, Right as follows:
5 Adjust the size of the webbrowser on the form, and leave a space between the webbrowser and the controlbox of the form:
6 Let's first assign the home page of the webbroser. The home page is the first page that appears when the Web Browser is loaded.
To do that, right click on the webbrowser and click on properties.
Change the property of URL to your favorite website:
7 Add two buttons to the form and place them between the form's header and the web browser. Change the text for each button to << and >> :
The button that text is << will do the Back command:
8 Double click on the button and the following code:
9 Double click on the button that text is >> and add the following code:
Add a text box and place it next to the Label:
11 Right click on the textbox and click on properties. In the properties window, change the anchor property to Top, Left, Right. The reason we do that is because when the web browser size changes by the user, the address bar's size will change too.
12 Add a button and place next to the textbox and change it's text to Go:
13 Change the Go button anchor property to Top, Right:
14 Double click on Go button and add the following code:
16 Change the 2 buttons anchor property to Top, Right:
17 Double click on Home button and add the following code:
1 Click on Project next to Create:
2 Click on Windows Form Application, and name the project "Your name's Application" and then click Ok.
You can change the form text to "your name's web browser". Click on the form and then go to properties window, then change the text property.
In the properties window, change the WindowState property to Maximized so that when the user launch the web browser, it will be maximized:
3 Add a Webbrowser from the toolbox.
Change the dock property
4 Right click on the webbrowser and click on properties. In the properties window change the Anchor property to Top, Bottom, Left, Right as follows:
5 Adjust the size of the webbrowser on the form, and leave a space between the webbrowser and the controlbox of the form:
6 Let's first assign the home page of the webbroser. The home page is the first page that appears when the Web Browser is loaded.
To do that, right click on the webbrowser and click on properties.
Change the property of URL to your favorite website:
7 Add two buttons to the form and place them between the form's header and the web browser. Change the text for each button to << and >> :
The button that text is << will do the Back command:
8 Double click on the button and the following code:
Code: Select all
The button that text is >> will do the Forward command:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
WebBrowser1.GoBack()
End Sub
9 Double click on the button that text is >> and add the following code:
Code: Select all
10 Add a Label next to the 2 buttons and change the text to Address:Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
WebBrowser1.GoForward()
Add a text box and place it next to the Label:
11 Right click on the textbox and click on properties. In the properties window, change the anchor property to Top, Left, Right. The reason we do that is because when the web browser size changes by the user, the address bar's size will change too.
12 Add a button and place next to the textbox and change it's text to Go:
13 Change the Go button anchor property to Top, Right:
14 Double click on Go button and add the following code:
Code: Select all
15 Add another 2 buttons and change their text to Home and Refresh;Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
WebBrowser1.Navigate(TextBox1.Text)
End Sub
16 Change the 2 buttons anchor property to Top, Right:
17 Double click on Home button and add the following code:
Code: Select all
18 Double click on refresh button and add the following code:
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
WebBrowser1.GoHome()
End Sub
Code: Select all
Run your web browser and it should work fine.rivate Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
WebBrowser1.Refresh()