Solved

How disable Shift+Tab key

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

708 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

18 Experts available now in Live!

Get 1:1 Help Now