Welcome Guest, Not a member yet? Create Account  

Tutorial  How to Make A Web Browser
#1
(This post was last modified: 12-11-2017, 08:48 PM by King.)

Requirements:
Visual Studio 8-10-12-13 (code may vary)
A fair knowledge of navigating Visual Studio


Screenshots are not included in this tutorial.

Step 1:
Create a New Project and title it whatever you want; For this example I am using "WebBrowser"

Step 2:
Add 5 Buttons, a Textbox, and a WebBrowser component to the form.

Step 3:
Change the button text for each button like this:
Button1: Back
Button2: Forward
Button3: Refresh
Button4: Stop
Button5: Go


Step 4:
Arrange all the buttons and the textbox at the top however you want them. Then make the WebBrowser component take up the rest of the space on the form.

Step 5:
Double click the "Back" button. Your code view should come up in a new tab. Inside the back button click function put this code:
Code:
WebBrowser1.GoBack()
Step 6:
Double click the "Forward" button. Your code view should come up in a new tab. Inside the forward button click function put this code:
Code:
WebBrowser1.GoForward()


Step 7:
Double click the "Refresh" button. Your code view should come up in a new tab. Inside the refresh button click function put this code:
Code:
WebBrowser1.Refresh()

Step 8:
Double click the "Stop" button and insert this code:
Code:
WebBrowser1.Stop()

Step 9:
Double click the "Go" button and insert this code:
Code:
WebBrowser1.Navigate(TextBox1.Text)

Step 10 (Optional):
Select the WebBrowser component and find the "Actions" panel (there should be a button with a lightning bolt picture on it near the properties panel; click it) Then find the "DocumentReady" (may be "DocumentComplete") function and then double click it.

Step 11 (goes along with step 10):
Inside the "DocumentReady" function insert this code:

Code:
TextBox1.Text = WebBrowser1.Url.ToString()

Step 12 (Optional):
Select the Textbox and go to the actions panel and find the "KeyDown" function. Double click it. Insert this code into the KeyDown function:
Code:
If e.KeyCode = Keys.Enter Then
WebBrowser1.Navigate(TextBox1.Text)
End If
e.SuppressKeyPress = True

Step 13:
Press "F5" on your keyboard. (this will debug your program and let you test it)
Likes 0
Likes 0
Reply




  1 Guest(s)