C# Equivalent To VB WithEvents?

I have a form with a tabcontrol, and each tab has a webbrowser control. I have declared a form variable, curWebBrowser, of type, WebBrowser, that gets set to the current, visible webbrowser control when the user clicks on its tab. I would like to handle all webbrowser events via curWebBrowser, rather than code event handlers for every webbrowser control. Is there a way to do this in C#?

TIA,
rca

[410 byte] By [rca] at [2007-12-16]
# 1
Hi,

To handle an event in C#,


Form1 myForm = (Form1) this.ActiveMDIChild;

myForm.Activated += EventHandler(myForm_Activated);
...
private void myForm_Activated(object sender, EventArgs e) {
// Handle the event
}

cheers,

Paul June A. Domag

PaulDomag at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...
# 2
Paul,

Forgive my ignorance. I am just now making the switch to .NET.

I think I see what you are describing. It looks similar to the way I did OO programing in C on UNIX long before the advent of OO languages like C++.

Correct me if I'm wrong. It looks like you are assigning a pointer to a function and then assigning that function to an event. Is that correct?

I'm hoping that I'm correct, because it would open up a whole cornucopia of possibilities.

Is this "delegation"? Or is that something different?

Thanks,
rca

rca at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...
# 3
Hi,
Yep you quite got it right. Here are some additional docs...
http://msdn2.microsoft.com/library/awbftdfh(en-us,vs.80).aspx
http://msdn2.microsoft.com/library/ms173171(en-us,vs.80).aspx

cheers,
Paul June A. Domag

PaulDomag at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...