WebBrowser事件属性? [英] WebBrowser Event Properties?
本文介绍了WebBrowser事件属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如(标准winforms应用程序与网络浏览器控件)
命名空间Crawler {
公共部分类Form1:表单{
WebCrawler.manager m;
public Form1(){
InitializeComponent();
}
private void Form1_Load(object sender,EventArgs e){
system.windows.forms.webbrowser wb = new system.windows.forms.webbrowser();
wb.DocumentCompleted + = new WebBrowserDocumentCompletedEventHandler(foo);
// [...其他代码...]
/ * [开始示例] * /
if(wb.DocumentCompleted 。包含(foo){
// Behave通常
} else {
//做某事...
}
}
}
}
如果我可以做一些像上面描述的那样,那么怎么样?
解决方案
你可以调用 Deletegate.GetInvocationList
。 p>
这是一个例子:
使用System;
使用System.Linq;
class程序
{
static event Action foo;
static void bar(){}
static void Main()
{
foo + = bar;
bool contains = foo
。 GetInvocationList()
.Cast< Action>()
.Contains(bar);
}
}
Can I figure out if a function has already been assigned to an event?
e.g. (Standard winforms app with web browser control)
namespace Crawler {
public partial class Form1 : Form {
WebCrawler.manager m;
public Form1() {
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e) {
system.windows.forms.webbrowser wb = new system.windows.forms.webbrowser();
wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(foo);
//[... Some other code ...]
/* [Begin Example] */
if (wb.DocumentCompleted.Contains(foo){
// Behave Normally
}else {
// Do Something Else...
}
}
}
}
And, if I can do something like I described above, then how?
解决方案
You can call Deletegate.GetInvocationList
.
Here is an example:
using System;
using System.Linq;
class Program
{
static event Action foo;
static void bar() { }
static void Main()
{
foo += bar;
bool contains = foo
.GetInvocationList()
.Cast<Action>()
.Contains(bar);
}
}
这篇关于WebBrowser事件属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文