Re: How to do "WithEvents" in C#?
- From: "Brett" <no@xxxxxxxx>
- Date: Tue, 3 May 2005 09:34:02 -0400
Some of the online examples I've seen for events in C# make use of
delegates. No one in this thread has used delegates. Why not?
Here are a few examples that use delegates:
http://www.c-sharpcorner.com/Code/2002/Mar/EventHandlingInNetUsingCSDD001.asp
http://www.codeproject.com/csharp/csevents01.asp
Brett
"Bob Powell [MVP]" <bob@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:uiyOGp5TFHA.3392@xxxxxxxxxxxxxxxxxxxxxxx
The .Paint part was just an example of a well-known event.
In your particular case you can declare the object and add the handler like
so:
AxSHDocVw.AxWebBrowser axWebBrowser1 = new AxSHDocVw.AxWebBrowser();
this.axWebBrowser1.DocumentComplete += new
AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEventHandler(this.axWebBrowser1_DocumentComplete);
--
Bob Powell [MVP]
Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
"Brett" <no@xxxxxxxx> wrote in message
news:OQP$MT0TFHA.2812@xxxxxxxxxxxxxxxxxxxxxxx
>
> "Bob Powell [MVP]" <bob@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:%23AnUlF0TFHA.2520@xxxxxxxxxxxxxxxxxxxxxxx
>> Don't worry about it. It's another example of keyword diarrhea in VB. It
>> fits right in with the idiocy of "overloads overrides" and the VB
>> compilers insistence on seeing the Readonly keyword even when it can see
>> that there is no set accessor.
>>
>> If a class exposes public events then you can add a handler to them using
>> the += operator such as...
>>
>> theForm.Paint+=new PaintEventHandler(this painthandler); // This is the
>> equivalent of AddHandler
>
> Using my code, what is the .Paint part? Would that be InternetExplorer?
>
> I'm not quite sure how to build the following in C#:
> [VB.NET]
> Private WithEvents IE_Inst As New SHDocVw.InternetExplorer
>
> Maps to things such as:
> Public Sub IEDocComplete(ByVal pDisp As Object, ByRef URL As Object)
> Handles
> IE_Inst.DocumentComplete
>
> Brett
>
>
.
- References:
- How to do "WithEvents" in C#?
- From: Brett
- Re: How to do "WithEvents" in C#?
- From: Bob Powell [MVP]
- Re: How to do "WithEvents" in C#?
- From: Brett
- How to do "WithEvents" in C#?
- Prev by Date: Re: Web Services DNS Round Robin
- Next by Date: Re: How to get " TOP(X)" rows from a DataView?
- Previous by thread: Re: How to do "WithEvents" in C#?
- Next by thread: Re: How to do "WithEvents" in C#?
- Index(es):
Relevant Pages
|