Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2006-06-14
3
Medium Priority
?
473 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 400 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 1600 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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…
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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
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

604 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