webbrowser with tabcontrol

R

RobcPettit

Hi, Ive added a tabcontrol to form1 and a webbrowser to tabpage, but
I cant see my page. Im using this in form load.
webBrowser1.Navigate("http://www.oddschecker.com/bet-basket"); Ive
checked the address, and Ive tried it with webbrowser in a form and it
works. Its firing private void webBrowser1_DocumentCompleted, so tits
trying. Is there something I have to add because its in a tabpage.
Regads Robert
 
M

Marc Gravell

Nothing special... see below which hosts 5 browsers on tabs; note that
WebBrowser might not truly load if it isn't Visible. Check that your
browser is actually *inside* the tab page, and not behind it. The
"Document Outline" window can make this easier to see.

Marc

using System;
using System.Windows.Forms;


static class Program {
[STAThread]
static void Main() {
Application.EnableVisualStyles();
using (Form f = new Form())
using (TabControl tc = new TabControl()) {
for (int i = 0; i < 5; i++) {
TabPage page = new TabPage("Page " + i.ToString());
tc.TabPages.Add(page);
WebBrowser wb = new WebBrowser();
wb.Name = "WB" + i.ToString();
f.Load += delegate {
wb.Navigate(@"http://www.google.com");
};
wb.DocumentCompleted += delegate {
f.Text += ";" + wb.Name;
};
wb.Dock = DockStyle.Fill;
page.Controls.Add(wb);
}
tc.Dock = DockStyle.Fill;
f.Controls.Add(tc);
Application.Run(f);
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

ie webpage 2 2
WebBrowserComplete only firing once. 2
Select All 3
webBrowser 1
Clearing a WebBrowser control 1
WebBrowser control to invoke silverlight 2
c# Favorites 5
Beginner TabControl question 1

Top