How to capture SHIFT + TAB in C# form

O

orekinbck

Hi There

In a C# windows app in .NET 2003, I would like to capture when the user
is within a certain text box and holds down shift then presses tab.

Atm, my code is:

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
const int WM_KEYDOWN = 0x100;
const int WM_SYSKEYDOWN = 0x104;
if ((msg.Msg == WM_KEYDOWN) || (msg.Msg == WM_SYSKEYDOWN))
{
if (keyData.ToString().Trim() == "Tab, Shift" && myTextBox.Focused)
{
DoMyThing();
return true;
}
}
return base.ProcessCmdKey(ref msg,keyData);
}

I don't like the evaluator 'keyData.ToString().Trim() == "Tab, Shift',
is there a better way?

TIA
Bill
 

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