[C#]How To Make A Basic Web Browser[C#]

Discussion in 'Archives' started by Dark L3g3nd, Dec 28, 2010.

[C#]How To Make A Basic Web Browser[C#]
  1. Unread #1 - Dec 28, 2010 at 11:26 AM
  2. Dark L3g3nd
    Joined:
    Mar 9, 2010
    Posts:
    157
    Referrals:
    0
    Sythe Gold:
    0

    Dark L3g3nd Active Member
    Banned

    [C#]How To Make A Basic Web Browser[C#]

    Well seeing as i have helped a couple of people with this lately i thought i might make this. A web browser was one of my first applications i made. I made this in Visual Studio 2008 but 2010 is out now but it should be very similar.

    Step 1: Requirements
    • Microsoft Visual Studio 2010 C# Edition Download Here
    • A Brain Is Always Good

    Step 2: Creating The Project
    Open up Microsoft Visual Studio 2008 C# Edition and select create project.
    Now you should see something like this:

    [​IMG]


    Choose "Windows Form Application" And then name it Web Browser or whatever, then click Ok.


    Step 3: Creating The GUI Side Of The Browser
    Now you should see something like this:

    [​IMG]


    Make it a bit bigger so it should now look like this:

    [​IMG]


    Now go into your Tool Box and Drag five buttons and a Text Box And A Label onto the GUI

    [​IMG]

    [​IMG]

    [​IMG]

    Now rename the buttons to: ()=The button number you use.By Doing This:

    Back(Button1), Forward(Button2), Stop(Button3), Refresh(Button4), Go(Button5), URL(Label1).


    [​IMG]


    Also rename the title of your application by clicking on the top of it where the close button is etc, and then do how you did for the buttons.


    Now drag them and line them up across the top and put them in this order.
    Code:
    [Back] [Forward] [Stop] [Refresh] {Label} (Text Box) [Go]
    It should now look like this:

    [​IMG]

    Now go back to your Tool Box and drag a Web Browser Control to your GUI and expand it to all the space left.

    [​IMG]

    It should now look something like this:

    [​IMG]


    Step 4: Adding The Code
    Ok so now we have our GUI done but if you click the buttons it won't do anything. We need to add the functions to the buttons. Let's start with the Back button.
    Double click the back button.


    Now in between the { and the } it brings you to add this:

    Code:
    webBrowserControl1.GoBack();
    This tells your web browser to go back pretty simple aye?


    Now let's do the Forward button double click it and in between the { and } it brings you to add this:

    Code:
    webBrowserControl1.GoForward();
    This tells your web browser to go forward.

    Now it's time for the Stop button so double click and in between the { and } it brings you to add this:

    Code:
    webBrowserControl1.Stop();
    This Tells your web browser to Stop, easy as pie don't you think?

    Now lets do the Refresh button so double click it and in between the { and } it brings you to add this:

    Code:
    webBrowserControl1.Refresh();
    This Tells your web browser to refresh.

    Now the Go button is the one that is a bit different, so double click it and in between the { and } it brings you to add this:

    Code:
    webBrowserControl1.Navigate(textBox1.Text);
    This tells your web browser to go to whatever address is in the text box you added.

    Your end code should look like this:

    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    
    namespace Web_Browser
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                webBrowser1.GoBack();
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
                webBrowser1.GoForward();
            }
    
            private void button3_Click(object sender, EventArgs e)
            {
                webBrowser1.Stop();
            }
    
            private void button4_Click(object sender, EventArgs e)
            {
                webBrowser1.Refresh();
            }
    
            private void button5_Click(object sender, EventArgs e)
            {
                webBrowser1.Navigate(textBox1.Text);
            }
        }
    }
    
    Step 5: Building Your Project
    We're all done now i recommend you save and you will need to build your web browser by doing this:

    [​IMG]


    Now go to where you saved it to and open the folder then go Bin>>Release>>Web Browser (or whatever you named it) and double click it.

    Enjoy
     
  3. Unread #2 - Jan 18, 2011 at 12:51 AM
  4. Zulwarn
    Joined:
    Jun 29, 2010
    Posts:
    374
    Referrals:
    1
    Sythe Gold:
    0

    Zulwarn Forum Addict
    Banned

    [C#]How To Make A Basic Web Browser[C#]

    Outstanding guide!

    +1 to you
     
  5. Unread #3 - Jan 18, 2011 at 2:26 AM
  6. Dark L3g3nd
    Joined:
    Mar 9, 2010
    Posts:
    157
    Referrals:
    0
    Sythe Gold:
    0

    Dark L3g3nd Active Member
    Banned

    [C#]How To Make A Basic Web Browser[C#]

    Thanks man, Did you try it?
     
  7. Unread #4 - Jan 25, 2011 at 7:40 AM
  8. OwenWant
    Joined:
    Dec 16, 2008
    Posts:
    575
    Referrals:
    0
    Sythe Gold:
    0

    OwenWant Forum Addict
    Banned

    [C#]How To Make A Basic Web Browser[C#]

    Thx great guide =] I cant try it out cause i aint got the program but good to know how things work xD
     
< Runescape 100% FACT! | Monkey Brah MM Application: Getting Proofs >

Users viewing this thread
1 guest


 
 
Adblock breaks this site