That all works but now I got to control the browser a bit (navigating, back, forward, ...). How do I access that browser in the selected tab?
Code:
Spoiler: Click to Toggle the Spoiler.
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 Browser
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void BtnAddNewTab_Click(object sender, EventArgs e)
{
//add a new page.
tabControl1.TabPages.Add("New Tabpage");
//create the new browser.
WebBrowser newBrowser = new WebBrowser();
//select the last tab. Can this be shorter?
tabControl1.SelectedTab = tabControl1.TabPages[tabControl1.TabCount - 1];
//add the browser to the tab.
tabControl1.SelectedTab.Controls.Add(newBrowser);
//edit the properties of the new browser.
newBrowser.Dock = DockStyle.Fill;
newBrowser.Navigate("http://www.google.be/");
}
private void BtnNavigate_Click(object sender, EventArgs e)
{
???.Navigate(TxtUrl.Text);
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Browser
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void BtnAddNewTab_Click(object sender, EventArgs e)
{
//add a new page.
tabControl1.TabPages.Add("New Tabpage");
//create the new browser.
WebBrowser newBrowser = new WebBrowser();
//select the last tab. Can this be shorter?
tabControl1.SelectedTab = tabControl1.TabPages[tabControl1.TabCount - 1];
//add the browser to the tab.
tabControl1.SelectedTab.Controls.Add(newBrowser);
//edit the properties of the new browser.
newBrowser.Dock = DockStyle.Fill;
newBrowser.Navigate("http://www.google.be/");
}
private void BtnNavigate_Click(object sender, EventArgs e)
{
???.Navigate(TxtUrl.Text);
}
}
}
[Close]
EDIT: Found it...
(WebBrowser)tabControl1.SelectedTab.Controls[0]