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.
"If glory comes after death, I have no hurry"
Marcial