How to capture SHIFT + TAB in C# form

  • Thread starter Thread starter orekinbck
  • Start date Start date
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
 
Back
Top