public Form1()
{
InitializeComponent();
tabControl1.TabPages.Clear(); // Get rid of any existing pages in the tab control
Create_a_new_tab(); // This method creates a new tab, new webbrowser and opens the default page.
WebBrowser webpage = GetCurrentWebBrowser(); // Get the current webpage and..
webpage.GoHome(); // ...display the default page.
}
private void Create_a_new_tab()
{
// Add a new tab control, and put a web control in it.
// Let's have a maxium of 10 tabs to keep things sane. if (current_tab_count == 10) return; // Create the new tab page
TabPage newpage = new TabPage("Loading..."); // Create the new page
tabpages.Add(newpage); // Add the page to an arraylist to keep track of it.
tabControl1.TabPages.Add(newpage); // Add the page to the TabControl so it actually appears
// Keep track of how many pages are open.
current_tab_count++; // Create a new WebBrowser control.
WebBrowser webpage = new WebBrowser(); // Create the new control
webpages.Add(webpage); // Add the control to an arraylist to keep track of it.
webpage.Parent = newpage; // Make sure the WebControl's parent is the TabControl page
webpage.Dock = DockStyle.Fill; // Make the WebControl fill the entire TabControl page.
// We define a handler to perform some actions when the document has been fetched and displayed.
// We need to do this as the WebControl will work in the background, and we need to know when it has
// finished so we can switch off the animation timer, and update the name of the Tab with the
// the document title.
webpage.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webpage_DocumentCompleted);
// webpage.GoHome(); // Display the default page.
timer1.Enabled = true; // Start the timer for animating the little logo in the top right. // Bring the new page to the foreground
tabControl1.SelectedTab = newpage;
}
private WebBrowser GetCurrentWebBrowser()
{
// This method returns the currently display WebControl.
// We use an arraylist of webpages, and find the right one by getting the index
// of the current tab. TabPage current_tab = tabControl1.SelectedTab;
WebBrowser thiswebpage = (WebBrowser)webpages[tabpages.IndexOf(current_tab)];
return thiswebpage;
}
{
InitializeComponent();
tabControl1.TabPages.Clear(); // Get rid of any existing pages in the tab control
Create_a_new_tab(); // This method creates a new tab, new webbrowser and opens the default page.
WebBrowser webpage = GetCurrentWebBrowser(); // Get the current webpage and..
webpage.GoHome(); // ...display the default page.
}
private void Create_a_new_tab()
{
// Add a new tab control, and put a web control in it.
// Let's have a maxium of 10 tabs to keep things sane. if (current_tab_count == 10) return; // Create the new tab page
TabPage newpage = new TabPage("Loading..."); // Create the new page
tabpages.Add(newpage); // Add the page to an arraylist to keep track of it.
tabControl1.TabPages.Add(newpage); // Add the page to the TabControl so it actually appears
// Keep track of how many pages are open.
current_tab_count++; // Create a new WebBrowser control.
WebBrowser webpage = new WebBrowser(); // Create the new control
webpages.Add(webpage); // Add the control to an arraylist to keep track of it.
webpage.Parent = newpage; // Make sure the WebControl's parent is the TabControl page
webpage.Dock = DockStyle.Fill; // Make the WebControl fill the entire TabControl page.
// We define a handler to perform some actions when the document has been fetched and displayed.
// We need to do this as the WebControl will work in the background, and we need to know when it has
// finished so we can switch off the animation timer, and update the name of the Tab with the
// the document title.
webpage.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webpage_DocumentCompleted);
// webpage.GoHome(); // Display the default page.
timer1.Enabled = true; // Start the timer for animating the little logo in the top right. // Bring the new page to the foreground
tabControl1.SelectedTab = newpage;
}
private WebBrowser GetCurrentWebBrowser()
{
// This method returns the currently display WebControl.
// We use an arraylist of webpages, and find the right one by getting the index
// of the current tab. TabPage current_tab = tabControl1.SelectedTab;
WebBrowser thiswebpage = (WebBrowser)webpages[tabpages.IndexOf(current_tab)];
return thiswebpage;
}
解决方案 »
- C#怎样判断手持设备的网络连接用的是什么方式
- 关于c# 智能卡储物柜 读写卡程序问题
- SQL语句问题
- 求助:两次通过DateTime.Now获取的系统时间不相同
- 有没有做过web控件,我想问一下web控件的Desinger是咋样做的??有没有人给个例子!
- 怎么关不上啊???
- 如何用DataGrid来处理多表问题?
- 诚心问各位~关于try catch和throw 的我问题
- help me,难题,如何使用C#实现虚拟盘符?
- 关于ACCESS 的连接
- 本人在一个C#项目中调用了一个用VC开发的组件,现在想在组件进行运行时,发消息到C#相关的程序中,我自己定义了消息 ,在C#中却不能接收
- DropDownList绑定数据问题!!谢谢各位
可上面没看到啊~!
不知道他是怎么加载进去的