Solved

How disable Shift+Tab key

Posted on 2006-11-17
5
336 Views
Last Modified: 2008-02-01
Using .NET 1.1, Windows Forms

I have disabled the Tab key with the following code but how do I disable the Shift+Tab Key?

Thanks

San

 Protected Overrides Function ProcessDialogKey(ByVal keyData As System.Windows.Forms.Keys) As Boolean
        If Not _dt Is Nothing Then

            If keyData = Keys.Tab Then
                Return True
            End If

            Return MyBase.ProcessDialogKey(keyData)
        End If
    End Function
0
Comment
Question by:Sanmarie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 10

Assisted Solution

by:Kinger247
Kinger247 earned 150 total points
ID: 17968305
Could try:

Public Class Form2
    Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.KeyPreview = True
    End Sub

    Private Sub Form2_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If e.Shift And e.KeyData.Tab Then
            e.Handled = True
        End If
    End Sub
End Class
0
 

Author Comment

by:Sanmarie
ID: 17968513

Thanks but your suggestion doesn't work.
If I press shift by itself or Tab by itself, then it works. But shift+ tab is still enabled.

San
0
 
LVL 6

Accepted Solution

by:
riyazthad earned 200 total points
ID: 17968752
It will work only if your all controls tab stop is set to False.

Now try this code

    Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
        If e.KeyCode = Keys.Tab And e.Shift Then
            Me.Text = "Tab +Shift"
        Else
            Me.Text = "Tab Only"
        End If
    End Sub
0
 
LVL 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 150 total points
ID: 17969195
You can disable both Tab and Shift-Tab with this:

Public Class Form1
    Inherits System.Windows.Forms.Form

    Protected Overrides Function ProcessTabKey(ByVal forward As Boolean) As Boolean
        Return True
    End Function

End Class
0
 

Author Comment

by:Sanmarie
ID: 17976179
ProcessTabKey and keydown worked

Thanks all

San
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question