Solved

Disabling keys on the keyboard  for a project using a tab control in vb.net

Posted on 2006-06-14
3
466 Views
Last Modified: 2007-12-19
I have a vb.net Windows app heavily using the tab control.  I would like the user to navigate to the tab by actually clicking on the tab.  I noticed that the arrow keys will advance to the next tab.  Is there a way to disable those keys.  I realize that I might be able to disable the tab and enable on the click event but that alone is a little bit undesirable because I am already disabling certain tabs as a result of applying access rights.  Is there another way?
0
Comment
Question by:garyinmiami2003
[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
3 Comments
 
LVL 2

Assisted Solution

by:shy_talk
shy_talk earned 100 total points
ID: 16902499
The following code will cancel any keypress on the form.

Public Class Form1

 Private Sub Form1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress

      e.Handled = True
   End Sub
End Class


If you want to prevent specific keypresses then this should get you started, from the VB help:
   Private Sub keypressed(ByVal o As [Object], ByVal e As KeyPressEventArgs)
        ' The keypressed method uses the KeyChar property to check
        ' whether the ENTER key is pressed.

        ' If the ENTER key is pressed, the Handled property is set to true,
        ' to indicate the event is handled.

        If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then
            e.Handled = True
        End If
    End Sub 'keypressed

Good luck
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 400 total points
ID: 16902626
Use...

Public Class Form1

    Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean
        Select Case keyData
            Case Keys.Left, Keys.Right
                Dim ctrl As Control = Me.ActiveControl
                If (Not (ctrl Is Nothing)) AndAlso (TypeOf ctrl Is TabControl) Then
                    Return True
                End If

        End Select

        Return False
    End Function

End Class
0
 

Author Comment

by:garyinmiami2003
ID: 16905055
My thanks to you both.  To Idle_Mind:  That worked great

Many thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

691 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