如何创建标签tab1打开samsung.com tab2打开hp.com ...
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 browsergotosamsung
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.Navigate("http://www.samsung.com");
webBrowser2.Navigate("http://www.hp.com");
webBrowser3.Navigate("http://www.IBM.com");
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
}
private void webBrowser3_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
}
private void webBrowser2_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
webBrowser2.Size
}
}
}
答案 0 :(得分:3)
我猜,WebBrowser控件现在支持标签。您需要添加一个自己的TabControl,您可以在其中创建动态TabPages和基础WebBrowser控件:
private void NavigateInNewTab(string url)
{
// browser tab
TabPage newBrowserTab = new TabPage();
// the underlying browser
WebBrowser newBrowser = new WebBrowser();
newBrowser.Dock = DockStyle.Fill;
newBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(newBrowser_DocumentCompleted);
// add tab and its browser to the tab control
newBrowserTab.Controls.Add(newBrowser);
this.tabControl1.TabPages.Add(newBrowserTab);
// navigate and focus new tab
newBrowserTab.Select();
newBrowser.Navigate(url);
}
void newBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
WebBrowser browser = (WebBrowser)sender;
TabPage browserTab = (TabPage)browser.Parent;
browserTab.Text = string.Format("{0} ({1})", browser.DocumentTitle, e.Url);
}
private void Form1_Load(object sender, EventArgs e)
{
this.NavigateInNewTab("http://www.example1.com");
this.NavigateInNewTab("http://www.example2.com");
}
答案 1 :(得分:0)
制作一个标签控件和一个标签浏览器webbrowser