Nelson,
I'd say the Click event is not a good example, since nothing's done normally in a Click event that you'd need to override. Unless you're talking about overriding the event in a sub-class of a sub-class. In that case, make sure that in your button's base class you define the Click handler as virtual so that it can be overridden in your sub-classes:
protected virtual Click_Handler(object sender, System.EventArgs e)
{
}
Then, in your sub-classed Click handler, you use override:
private override Click_Handler(object sender, System.EventArgs e)
{
base.Click_Handler(sender, e);
}
I think I got it right (this is untested code off the top of my head) ...
~~Bonnie
>Hi Bonnie,
>
>BTW is this type of functionality available for *All* events. I ask this because I have only seen the Handled property in the KeyEventArgs and KeyPressEventArgs classes.
>
>Is it possible to achive this with other events such as click, etc?
>
>Thanks in advance.
>
>
>
>>> Nelson,
>
>You *can* handle a KeyPress event in a sub-class of a TextBox:
>
>// In the sub-class's Contstructor:
>this.KeyPress += new KeyPressEventHandler(this.KeyPressHandler);
>
>// and then the Handler:
>protected virtual void KeyPressHandler(object sender, System.Windows.Forms.KeyEventArgs e)
>{
> if (e.KeyCode == Keys.PageDown)
> {
> // or whatever it is you're checking for, handle it here and then include this:
> e.Handled = true;
> }
>}
>
>For KeyPresses that you don't handle, e.Handled will not be true and C# will process the KeyPress as normal.