Key Down Event in Text Box

O

orekinbck

Hi

How do I catch a SHIFT TAB in the key down event of a text box?

Thanks
Bill
 
M

Morten Wennevik

Hi Bill,

The TextBox KeyDown event won't receive a TAB unless you set the TextBox.Multiline = true as well as TextBox.AcceptsTab = true. If this is unwanted you can however override PreProcessMessage in an inherited TextBoz

class MyTextBox : TextBox
{
public override bool PreProcessMessage(ref Message msg)
{
if((int)msg.WParam == 9 && Control.ModifierKeys == Keys.Shift)
MessageBox.Show("SHIFT-TAB");
return base.PreProcessMessage (ref msg);
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top