private void button5_Click(object sender, EventArgs e)
{
if (domainUpDown2.Text == "Battlefield: Bad Company 2")
{
Form2 form2 = new Form2();
form2.ShowDialog();
}
}
All that does is open a new blank form, but i need it to open a new form with a webbrowser in it so i can set it url dependent on the if 开发者_C百科statement..
Assuming your form2 has a WebBrowser control, and that it has a property you can set like this:
public Uri WebLocation
{
set { webBrowser1.Url = value; }
}
Then modify your code as follows:
private void button5_Click(object sender, EventArgs e)
{
Form2 form2 = new Form2();
if (domainUpDown2.Text == "Battlefield: Bad Company 2")
form2.WebLocation = new Uri("http://badcompany2.yoursite.com");
if (domainUpDown2.Text == "Some Other Item")
form2.WebLocation = new Uri("http://someotheritem.yoursite.com");
form2.ShowDialog();
}
精彩评论