问题描述
这个VB.NET代码的C#等价物是什么:
Private WithEvents IE_Inst As New SHDocVw.InternetExplorer
我得到:
private SHDocVw.InternetExplorer IE_Inst = new SHDocVw.InternetExplorer();
但我不知道如何翻译WithEvents部分。有什么建议吗?
谢谢,
Brett
What is the C# equivalent for this VB.NET code:
Private WithEvents IE_Inst As New SHDocVw.InternetExplorer
I get as far as:
private SHDocVw.InternetExplorer IE_Inst = new SHDocVw.InternetExplorer();
but am not sure how to translate the WithEvents part. Any suggestions?
Thanks,
Brett
推荐答案
C#不直接支持WithEvents 。
看看C#和VB.NET之间的区别
您的问题:
你必须定义每个事件,你要在哪里使用事件处理程序,
明确:
SHDocVw.Event1 + = new EventHandler( HandleEvent_Function1);
SHDocVw.Event2 + = new EventHandler(HandleEvent_Function2);
....
hth
thoean
C# does not support WithEvents directly.
Have a look at differences between C# and VB.NET at
http://www.codeproject.com/dotnet/vb...difference.asp
To your question:
You have to define each event, where you want to use an event handler,
explicitly:
SHDocVw.Event1 += new EventHandler(HandleEvent_Function1);
SHDocVw.Event2 += new EventHandler(HandleEvent_Function2);
....
hth
thoean
C#不直接支持WithEvents。
了解C#和VB.NET之间的差异
给你问题:
你必须明确地定义每个事件,你要在哪里使用事件处理程序:
SHDocVw.Event1 + = new EventHandler(HandleEvent_Function1);
SHDocVw.Event2 + = new EventHandler(HandleEvent_Function2);
....
hth
thoean
C# does not support WithEvents directly.
Have a look at differences between C# and VB.NET at
http://www.codeproject.com/dotnet/vb...difference.asp
To your question:
You have to define each event, where you want to use an event handler,
explicitly:
SHDocVw.Event1 += new EventHandler(HandleEvent_Function1);
SHDocVw.Event2 += new EventHandler(HandleEvent_Function2);
....
hth
thoean
这篇关于怎么做“WithEvents”在C#?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!