A
Adam
Hello. I have a form which derives from a System.Windows.Forms.Form.
On the derived form, I would like to override a button's onclick event,
and perform some validation on the derived form, then finally call the
base class' onclick event.
I have tried the following with no success. The derived class' event is
being called twice. I know this is because both buttons are wired to
call the onclick event. However, I would like a solution where I don't
have to change the code in the base class.
Should I just remove the base handler from the derived? I could do
this, but then what would be the syntax for calling the base class'
onclick?
Thanks in advance.
base class:
protected virtual void button1_Click(object sender, System.EventArgs e)
{
MessageBox.Show("in 1");
}
derived class:
protected override void button1_Click(object sender, System.EventArgs
e)
{
MessageBox.Show("in 2");
}
On the derived form, I would like to override a button's onclick event,
and perform some validation on the derived form, then finally call the
base class' onclick event.
I have tried the following with no success. The derived class' event is
being called twice. I know this is because both buttons are wired to
call the onclick event. However, I would like a solution where I don't
have to change the code in the base class.
Should I just remove the base handler from the derived? I could do
this, but then what would be the syntax for calling the base class'
onclick?
Thanks in advance.
base class:
protected virtual void button1_Click(object sender, System.EventArgs e)
{
MessageBox.Show("in 1");
}
derived class:
protected override void button1_Click(object sender, System.EventArgs
e)
{
MessageBox.Show("in 2");
}