Chat LIVE With Programming Experts! There Are 23 Online Right Now...

Welcome to Dream.In.Code
Become a C# Expert!

Join 244,180 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,349 people online right now. Registration is fast and FREE... Join Now!




Create a WebBrowser

 
Reply to this topicStart new topic

> Create a WebBrowser, Step-by-Step Tutorial

gbertoli3
Group Icon



post 29 Jul, 2008 - 09:24 AM
Post #1


In this Tutorial I will show you how to create your very own webbrowser.

You will need: 1 Toolstrip + ToolStrip Controls(explained later), 1 WebBrowser.

First thing is first, drag a toolstrip from the toolbox onto the form. Make sure that the Grip Visibility is set to Hidden.

IPB Image

Now we will add the controls. You will need:(6 ToolStripButtons, 1 ToolStripLabel, and 1 ToolStripTextBox). Now we will set the names of the controls. The first button will be called back, the second forward, the third refresh, the fourth stop, the fifth home and the last GO. For the GO button set the alignment property to right. Now that you have the names we can set each of the button's DisplayStyle to Image. Set the proper images for each button. Now we will name the label and the textbox on the toolstrip. For the Label set the text property to URL: and the name to urlLabel. Now the textbox will be named url and the text leave blank.


Next drag the WebBrowser Control onto the form.

IPB Image

Set the name property of the webbrowser to webBrowser

Now for the coding.

Double-Click on the Form and enter this code webBrowser.GoHome();.
Double-Click on the Back Button and enter this code webBrowser.GoBack();.
Double-Click on the Forward Button and enter this code webBrowser.GoForward();.
Double-Click on the Refresh Button and enter this code webBrowser.Refresh();.
Double-Click on the Stop Button and enter this code webBrowser.Stop();.
Double-Click on the Home Button and enter this code webBrowser.GoHome();.
Double-Click on the GO Button and enter this code webBrowser.Navigate(url.Text);.
Double-Click on the webBrowser and enter this code url.Text = e.Url.ToString();.

This is what your final design should look like.

IPB Image

Now run the form and have fun!


Attached File(s)
Attached File  WebBrowserTutorial.zip ( 91.19k ) Number of downloads: 772
Go to the top of the page
+Quote Post


Register to Make This Ad Go Away!

dExIT
*



post 16 May, 2009 - 09:46 AM
Post #2
Thx, for this realy usefull tutorial, but i have questions :

1) How to lock the URL bar, for example, when the WebBrowser opens, it opens a website defined in the program's code, and shows the Adress in the URL bar, BUT the user cannot edit it...
1.1) Or how to remove the URL bar, but make the Browser start with a default start page ... like in IE its about:blank or whatever the user has defined, but in this case i would like it to start with my website...

2) How to remove the Scroll bar ?
Go to the top of the page
+Quote Post

gbertoli3
Group Icon



post 16 May, 2009 - 10:53 AM
Post #3
If I understand you correctly you are asking: 1. Hide the URL Text Box 2. Navigate to a page instead of Homepage on the load of the Browser 3. Remove the Scroll Bar?

1. Just type: urlTextBox.Visible = false;

2. Just type this in the OnLoad() Event: webBrowser1.Navigate("http://www.example.com");

3. Just set the WebBrowser's ScrollBarsEnabled Property to false or type: webBrowser1.ScrollBarsEnabled = false;

Hope this helps

This post has been edited by gbertoli3: 16 May, 2009 - 10:56 AM
Go to the top of the page
+Quote Post


Fast ReplyReply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 


Lo-Fi Version Time is now: 7/4/09 05:54AM

Live C# Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month