Inheriting an event handler

M

Michael Rodriguez

If I have an event handler defined in a base class form, why can I not
choose from it in the properties window of the descendant forms? I used to
use this all the time in Delphi.

Also, if I have to manually declare it in the child form and then pick it in
the properties window of the child, is this the correct way to do it:

protected override void bsrcMain_PositionChanged(object sender, EventArgs e)
{
// call base class code
base.bsrcMain_PositionChanged(sender, e);
// new code for this instance
FillAcctInfo();
}

TIA,

Mike Rodriguez
 
N

Nicholas Paldino [.NET/C# MVP]

Michael,

Hmm, I tried this in VS.NET 2005, and I would think that protected
members that fit the signature for an event handler would be listed, but it
is not. I'll have to list it as a bug. This also helped me discover
another bug.

I'll list them later tonight. Unfortunately, you will have to do this
manually until it is fixed.

As for how to do it, what you are doing looks correct, as long as the
method is declared virtual in the base class.

Hope this helps.
 
M

Michael Rodriguez

Thanks, Nicholas. I'm glad to hear that it should be working this way.
I'll log the bug on the msdn feedback site. Who knows, maybe I'll win a 2nd
t-shirt... <g>

Mike


Nicholas Paldino said:
Michael,

Hmm, I tried this in VS.NET 2005, and I would think that protected
members that fit the signature for an event handler would be listed, but
it is not. I'll have to list it as a bug. This also helped me discover
another bug.

I'll list them later tonight. Unfortunately, you will have to do this
manually until it is fixed.

As for how to do it, what you are doing looks correct, as long as the
method is declared virtual in the base class.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Michael Rodriguez said:
If I have an event handler defined in a base class form, why can I not
choose from it in the properties window of the descendant forms? I used
to use this all the time in Delphi.

Also, if I have to manually declare it in the child form and then pick it
in the properties window of the child, is this the correct way to do it:

protected override void bsrcMain_PositionChanged(object sender, EventArgs
e)
{
// call base class code
base.bsrcMain_PositionChanged(sender, e);
// new code for this instance
FillAcctInfo();
}

TIA,

Mike Rodriguez
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top