Captureing KeyDown event in custom text box control

PePe

Newcomer
Joined
Mar 23, 2004
Messages
7
Can someone help with the correct syntax for overriding the Keydown event of a textbox control? I'm having a heck of time getting it to compile. (Yup,..it's friday.) Thanks in advance.
PePe

public class cTextBox: System.Windows.Forms.TextBox
{
public cTextBox()
{
base.KeyDown += new System.EventHandler(OnKeyDown);

}

protected override void OnKeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
//trap escape key here.
}
}
 
Here's the correct syntax...

public class cTextBox: System.Windows.Forms.TextBox
{
public cTextBox()
{

}

protected override void OnKeyDown(System.Windows.Forms.KeyEventArgs e)
{
//trap escape key here.
MessageBox.Show("hello");
}


}
 
Back
Top