public static WebBrowser wb = new WebBrowser();
public static string GetPagesContent(WebpageModel webpage) {
wb.Navigate(webpage.Url);
wb.DocumentCompleted+=new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted);
return OperateArry();
}我想引用webbrowser类,而不是拖放控件,这样他的 DocumentCompleted 事件触发怎么写呢?
我上面写的怎么没有预期运行我定义的 DocumentCompleted 函数呢?应该怎么写,我错在哪里了?
public static string GetPagesContent(WebpageModel webpage) {
wb.Navigate(webpage.Url);
wb.DocumentCompleted+=new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted);
return OperateArry();
}我想引用webbrowser类,而不是拖放控件,这样他的 DocumentCompleted 事件触发怎么写呢?
我上面写的怎么没有预期运行我定义的 DocumentCompleted 函数呢?应该怎么写,我错在哪里了?
解决方案 »
- C# 奇异矩阵问题
- 如何让PictureBox在Dock为Fill的属性下显示滚动条
- WinForm 窗体中 信息如果没有保存,则不允许操作其他模块
- 关于C#委托的问题 什么时候该用委托
- c#or asp.net请留下你的一道面试题或是面试中有意义的谈话或是面试的一个效细节!
- 从事测试没多久,请各位提供点方法,资料,网站,以享小妹。谢谢了。
- 关于动态加载javascript的代码 大家看看
- 如何取得DataTable中某一列的最大值
- DataList中的内容转到详细内容该怎么办啊????(在线等.....)
- 大家评评怎么办?
- .net里面后台传值给前台
- asp.net中 怎么读取数据库的表后,手动把数据添加到表格中?
private void PrintHelpPage()
{
// Create a WebBrowser instance.
WebBrowser webBrowserForPrinting = new WebBrowser(); // Add an event handler that prints the document after it loads.
webBrowserForPrinting.DocumentCompleted +=
new WebBrowserDocumentCompletedEventHandler(PrintDocument); // Set the Url property to load the document.
webBrowserForPrinting.Url = new Uri(@"\\myshare\help.html");
}private void PrintDocument(object sender,
WebBrowserDocumentCompletedEventArgs e)
{
// Print the document now that it is fully loaded.
((WebBrowser)sender).Print(); // Dispose the WebBrowser now that the task is complete.
((WebBrowser)sender).Dispose();
}
wb.DocumentCompleted+=new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted);
这一句后,并没有执行 wb_DocumentCompleted 函数,这是为什么呢?
{ }
这样就注册上了
我就是这样写的,只是我写的是 static,事件没执行难道和 static 有关?