Capturing TAB key in VB.NET

  • Thread starter Thread starter Niksa Baldun
  • Start date Start date
N

Niksa Baldun

Hi,

I would like to process Ctrl + TAB key combination in Form_Keydown event,
but the event is not always triggered. I suppose that is because TAB key
gets special treatment. Is there any way to make TAB key behave just like
any other key? BTW, the form contains a TabControl and some RichTextBoxes.

Thanks,


Niksa
 
Try this, override the form's ProcessTabKey Event

Protected Overrides Function ProcessTabKey(ByVal forward As Boolean) As
Boolean
MessageBox.Show("Tab Pressed")
End Function
 
* "Niksa Baldun said:
I would like to process Ctrl + TAB key combination in Form_Keydown event,
but the event is not always triggered. I suppose that is because TAB key
gets special treatment. Is there any way to make TAB key behave just like
any other key? BTW, the form contains a TabControl and some RichTextBoxes.

Have a look at the form's 'Process*' methods. You can override them to
get the event.
 
You could also give this a try (Forms keypress = True).

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown

If e.Modifiers = Keys.Control Then
If e.KeyCode = Keys.Tab Then
MessageBox.Show("Tab pressed")
End If
End If
End Sub
 
Back
Top