I'm trying to make a simple web browser with tab support and am having difficulty with getting pages to load in the right tabs. I can make new windows and tabs and switch between them, however the web page typed in the address bar always loads in tab 0. I've never really used tab controls before and I'm kind of learning as I go.
I think I need somehow to almost dynamically name each new instance of webBrowser so they can be accessed individually but I don't know how to go about something like that.
Here's what I've got so far
TypeScript
privatevoidtoolStripTextBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13)
{
int currentTab = tabControl1.SelectedIndex;
MessageBox.Show(currentTab.ToString());
// tabControl1.SelectedTab.
webBrowser1.Navigate(toolStripTextBox1.Text);
// Identify selected tab from tabControl1 and use this // to load the requested URL in the current tab's web browser
}
}
privatevoidForm1_Load(object sender, EventArgs e)
{
webBrowser1.Navigate("http://www.google.co.uk");
}
privatevoidnewWindowToolStripMenuItem_Click(object sender, EventArgs e)
{
Form nextWindow = newForm1();
nextWindow.Show();
}
privatevoidnewTabToolStripMenuItem_Click(object sender, EventArgs e)
{
TabPage nextTab = newTabPage("Google");
tabControl1.TabPages.Add(nextTab);
tabControl1.SelectedTab = nextTab;
WebBrowser webBrowser1 = newWebBrowser();
nextTab.Controls.Add(webBrowser1);
webBrowser1.Dock = DockStyle.Fill;
webBrowser1.Navigate("http://www.google.co.uk");
}
Thank you for any help
Lewis
Answers
Know the answer? Post it. Somebody with the same question will find it here.
Answers
Know the answer? Post it. Somebody with the same question will find it here.