rishford
June 24th, 2008, 09:11 AM
Hi Guys,
Currently learning the basics of C Sharp programming and completed a tutorial on MSDN called "How to: Create a C sharp windows form application." Although the application is built and the form displays a webpage, when I change the URL and press the Go button the application stops working. The code is as follows:
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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
comboBox1.SelectedIndex = 0;
webBrowser1.GoHome();
}
private void goButton_Click(object sender, EventArgs e)
{
webBrowser1.Navigate(new Uri(comboBox1.SeletedItem.ToString()));
}
private void homeToolStripMenuItem_Click(object sender, EventArgs e)
{
webBrowser1.GoHome();
}
private void goBackToolStripMenuItem_Click(object sender, EventArgs e)
{
webBrowser1.GoBack();
}
private void goForwardToolStripMenuItem_Click(object sender, EventArgs e)
{
webBrowser1.GoForward();
}
}
}
Have I missed something? An exception also occurs sometimes: UriFormatException. Having followed the tutorial, I can't see where I have go wrong. Please help! Thanks
Rish
Currently learning the basics of C Sharp programming and completed a tutorial on MSDN called "How to: Create a C sharp windows form application." Although the application is built and the form displays a webpage, when I change the URL and press the Go button the application stops working. The code is as follows:
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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
comboBox1.SelectedIndex = 0;
webBrowser1.GoHome();
}
private void goButton_Click(object sender, EventArgs e)
{
webBrowser1.Navigate(new Uri(comboBox1.SeletedItem.ToString()));
}
private void homeToolStripMenuItem_Click(object sender, EventArgs e)
{
webBrowser1.GoHome();
}
private void goBackToolStripMenuItem_Click(object sender, EventArgs e)
{
webBrowser1.GoBack();
}
private void goForwardToolStripMenuItem_Click(object sender, EventArgs e)
{
webBrowser1.GoForward();
}
}
}
Have I missed something? An exception also occurs sometimes: UriFormatException. Having followed the tutorial, I can't see where I have go wrong. Please help! Thanks
Rish