First off start a new "Windows Forms Application" in visual studio.
The controls you'll need are:
Control-------Name of control------Text Displayed
ToolStrip toolStrip (none)
-button1 backButton Back
-button2 forwardButton Forward
-separator separator (none)
-label urlLabel URL:
-textBox urlTextBox *Starting Url* http:
-button3 goButton GO
ToolStrip2 statusStrip (none)
-label1 doneLabel Done
-label2 openingLabel Opening
-progressBar progressBar (none)
WebBrowser webBrowser (none)
ToolStrip
To add tools to your tool strip, if you don't know how, you simple click the drop down arrow to right of the repeat image on the toolstrip, and select the tool you want.
Go into the urlTextBox properties and set the Width of the textbox to 400.
If you have an image for you backButton, forwardButton, or goButton then go a head and use it, but if you don't just go in to the DisplayStyle Property and select Text. This should display what typed int the Text property.
Set the Enabled Property to false for both the backButton and the forwardButton.
This is what your toolStip Should look like:
(I Changed the Background color of the toolStrip from its defualt color for this tutorial so that its easyer to see)
StatusStrip
All you need to do right now is change the Alignment Property of the progressBar to Right, and set the Visible
Property of the doneLabel, openingLabel, and progressBar to False.
This is what your statusStip Should look like:
(I Changed the Background color of the statusStrip from its defualt color for this tutorial so that its easyer to see)
WebBrowser
The webBrowser's Dock Property should have been Fill by default but if its not then change it to Fill.
The 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 WebBrowser
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private string[] SiteMemoryArray = new string[100];
private int count = 0;
private void Form1_Load(object sender, EventArgs e)
{
webBrowser.Navigate("http://www.google.com/");
SiteMemoryArray[count] = urlTextBox.Text;
}
private void urlTextBox_Click(object sender, EventArgs e)
{
urlTextBox.SelectAll();
}
private void goButton_Click(object sender, EventArgs e)
{
webBrowser.Navigate(urlTextBox.Text);
}
private void backButton_Click(object sender, EventArgs e)
{
if (count > 0)
{
count = count - 1;
urlTextBox.Text = SiteMemoryArray[count];
webBrowser.Navigate(urlTextBox.Text);
forwardButton.Enabled = true;
}
}
private void forwardButton_Click(object sender, EventArgs e)
{
if (count < 100)
{
count = count + 1;
urlTextBox.Text = SiteMemoryArray[count];
webBrowser.Navigate(urlTextBox.Text);
backButton.Enabled = true;
count = count + 1;
if (SiteMemoryArray[count] == null)
{
forwardButton.Enabled = false;
}
count = count - 1;Subtracts 1 From Count Variable
}
}
private void webBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
doneLabel.Visible = false;
progressBar.Visible = true;
progressBar.Value = 0;
progressBar.Minimum = 0;
progressBar.Maximum = 100;
progressBar.Step = 10;
progressBar.PerformStep();
}
private void webBrowser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
progressBar.Step = 80;
progressBar.PerformStep();
urlTextBox.Text = webBrowser.Url.ToString();
openingLabel.Text = "Openning: " + urlTextBox.Text;
openingLabel.Visible = true;
}
private void webBrowser_DocumentCompleted(object sender,
WebBrowserDocumentCompletedEventArgs e)
{
progressBar.Step = 10;
progressBar.PerformStep();
progressBar.Visible = false;
openingLabel.Visible = false;
doneLabel.Visible = true;
if (SiteMemoryArray[count].ToString() != webBrowser.Url.ToString())
{
count = count + 1;
SiteMemoryArray[count] = urlTextBox.Text;
}
if (count > 0)
{
backButton.Enabled = true;
}
else
{
backButton.Enabled = false;
}
}
}
}
References
http://support.microsoft.com/kb/313068/ - Explans Some basic of the webBrowser control
http://msdn.microsoft.com/en-us/library/t9fzsyec(VS.85).aspx - Basics of The Progress Bar