Solved

How disable Shift+Tab key

Posted on 2006-11-17
5
332 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
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 85

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Hide Tab Page 3 34
Set form below another form 3 35
Vb. Net application freezes 9 30
Pagebreak issue while printing the aspx page 3 16
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…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

867 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now