Prevent Ctrl+Tab from Selecting TabPages
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
2 posts
Page 1 of 1
I google this question but none of the result answer my problem.
somebody help me with preventing Ctrl+Tab from selecting TabPages ?
I used e.KeyCodes on KeyDown Events in TabControl and it is not working.
somebody help me with preventing Ctrl+Tab from selecting TabPages ?
I used e.KeyCodes on KeyDown Events in TabControl and it is not working.
The way I found to fix this comes from this StackOverflow thread. The guy posting was trying to do something similar to you but in another .NET language, so I adapted it for VB.NET
Basically, you have to create a custom class that inherits TabControl, and then override the OnKeyDown sub so that you can ignore any keyboard input if the control, tab, shift or page up/down keys are pressed.
Here's the full code:
Basically, you have to create a custom class that inherits TabControl, and then override the OnKeyDown sub so that you can ignore any keyboard input if the control, tab, shift or page up/down keys are pressed.
Here's the full code:
Code: Select all
You can place this code under the "End Class" of your Form1 class or whatever it's called. Also, you'll have to build your project once before CustomTabControl appears in your toolbox. Once that's done, you'll be able to add it to your project like any other control, and it will behave like any other TabControl except that it won't switch tabs when you press Ctrl+Tab cooll;Public Class CustomTabControl
Inherits TabControl
Protected Overrides Sub OnKeyDown(ke As KeyEventArgs)
If (ke.KeyData = (Keys.Tab Or Keys.Control) Or ke.KeyData = (Keys.PageDown Or Keys.Control) Or ke.KeyData = (Keys.Tab Or Keys.Control Or Keys.Shift)) Then
Return
End If
MyBase.OnKeyDown(ke)
End Sub
End Class
2 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023