Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

}

}

Posted

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");

}

 

 

}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...