【发布时间】:2014-04-09 21:32:08
【问题描述】:
我正在尝试简单地将 webbrowser 控件添加到窗口,然后让它打开一个页面。我尝试了一个 Web URL 以及一个本地 HTML 文件,但无济于事。这是我的代码:
命名空间 qTab1 { 公共部分类Form1:表格 { 公共表格1() { 初始化组件(); }
private void Form1_Load(object sender, EventArgs e)
{
FileStream source = new FileStream("index.html", FileMode.Open, FileAccess.Read);
webBrowser1.DocumentStream = source;
//// When the form loads, open this web page.
//webBrowser1.Navigate("www.google.com");
}
private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
// Set text while the page has not yet loaded.
this.Text = "Navigating";
}
private void webBrowser1_DocumentCompleted(object sender,
WebBrowserDocumentCompletedEventArgs e)
{
// Better use the e parameter to get the url.
// ... This makes the method more generic and reusable.
this.Text = e.Url.ToString() + " loaded";
}
}
}
这是我目前的项目:
我做错了什么?
【问题讨论】: