Im using VB.NET and i do not want users to be able to cycle through the tab pages using Ctrl+Tab (or Ctrl+Shift+Tab).
I tried using the keydown event and setting
e.SuppressKeyPress =
True
But no dice.
nizmo Thursday, September 13, 2007 1:07 AM
Add a new class to your project and paste the code shown below. Build. Drop the new control from the top of your toolbox onto your form. This code prevents the TabControl.OnKeyDown() method from seeing the keystroke.
Public Class MyTabControl Inherits TabControl
Protected Overrides Sub OnKeyDown(ByVal key As System.Windows.Forms.KeyEventArgs) If key.KeyData = (Keys.Tab Or Keys.Control) Or key.KeyData = (Keys.Tab Or Keys.Control Or Keys.Shift) Then key.Handled = True Else MyBase.OnKeyDown(key) End If End Sub
End Class
nobugz Thursday, September 13, 2007 3:17 AM
Add a new class to your project and paste the code shown below. Build. Drop the new control from the top of your toolbox onto your form. This code prevents the TabControl.OnKeyDown() method from seeing the keystroke.
Public Class MyTabControl Inherits TabControl
Protected Overrides Sub OnKeyDown(ByVal key As System.Windows.Forms.KeyEventArgs) If key.KeyData = (Keys.Tab Or Keys.Control) Or key.KeyData = (Keys.Tab Or Keys.Control Or Keys.Shift) Then key.Handled = True Else MyBase.OnKeyDown(key) End If End Sub
End Class
nobugz Thursday, September 13, 2007 3:17 AM
Excellent, works perfectly... just like all the answers yougive me!
nizmo Thursday, September 13, 2007 3:23 AM
Hi,
When migrating project from VB to Vb.Net the TAB control behaviour is not good.Tab pages is not opening in the tab control by pressing Tab Key in VB.Net where as in VB it is working fine.Please help to solve the problem