?
Solved

How disable Shift+Tab key

Posted on 2006-11-17
5
Medium Priority
?
346 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 600 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 800 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 600 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

764 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