Hi,
I’m writing a C# program (using Visual Studio 2005 Professional Edition).
I have defined a class MyPanel in the following way:
In this class I have put a btn Button control, and I have defined the event handler:
Then, I have defined another class, inherited from MyPanel:
In this class I would like to enrich the btn_Click event handler (the code of the base class should be executed anyway), but I don’t know why…
If it were a method, as for example
in the inherited class I could write:
but if I want to enrich an event handler and not a method, how can I do? (I have tried to add the “protected” keyword in the event handler definition of MyPanel base class:
but when I go in the inherited class and try to write “protected override”, the methods list the compiler shows me doesn’t include this event handler…
Can you give me any suggestion about that?
Thank you very much
I’m writing a C# program (using Visual Studio 2005 Professional Edition).
I have defined a class MyPanel in the following way:
Code:
class MyPanel : Panel
{
...
}
In this class I have put a btn Button control, and I have defined the event handler:
Code:
btn.Click += new EventHandler(btn_Click);
...
void btn_Click(object sender, EventArgs e)
{
...
}
Then, I have defined another class, inherited from MyPanel:
Code:
class MyPanel2 : MyPanel
{
...
}
In this class I would like to enrich the btn_Click event handler (the code of the base class should be executed anyway), but I don’t know why…
If it were a method, as for example
Code:
protected void InitializeControls()
{
...
}
in the inherited class I could write:
Code:
protected override void InitializeControls()
{
base.InitializeControls();
...
}
but if I want to enrich an event handler and not a method, how can I do? (I have tried to add the “protected” keyword in the event handler definition of MyPanel base class:
Code:
protected void btn_Click(object sender, EventArgs e)
{
...
}
but when I go in the inherited class and try to write “protected override”, the methods list the compiler shows me doesn’t include this event handler…
Can you give me any suggestion about that?
Thank you very much