111,120
社区成员
发帖
与我相关
我的任务
分享using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
PrintHelpPage("http://www.psno1.com");
PrintHelpPage("http://www.baidu.com");
PrintHelpPage("http://www.google.com");
PrintHelpPage("http://www.yahoo.com.cn");
PrintHelpPage("http://www.bing.com");
}
private void PrintHelpPage(string websiteurl)
{
WebBrowser wb = new WebBrowser();
wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(PrintDocument);
//如何构造 wb的NewWindows事件呢?
wb.Navigate(websiteurl);
wb.Dock = DockStyle.Fill;
wb.ScriptErrorsSuppressed = true;
if (websiteurl.Length > 10)
{
tabControl1.TabPages.Add(websiteurl.Substring(0, 10) + "...");
}
else
{
tabControl1.TabPages.Add(websiteurl);
}
tabControl1.TabPages[tabControl1.TabPages.Count - 1].Controls.Add(wb);
}
private void PrintDocument(object sender, WebBrowserDocumentCompletedEventArgs e)
{
//已知 ((WebBrowser)sender).DocumentTitle 获取标题!
//如何让 tabControl1 每个选项卡的标题对应相应的网页
//例如第一个选项卡是"设计一线网站标题",第二个选项卡是"百度",第三个选项卡是"Google" ... ...
}
}
}