• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 810
  • Last Modified:

check if Ctrl-Key is pressed...


My problem is the following:

I want that if I press the CTRL-Key that label1 should show "Multiple Selection possible"

I have this code:

    Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
        If e.KeyCode = Keys.ControlKey Then
            Label1.Text = "Multiple Selection possible"
        End If
    End Sub

And that is working but if I place a textbox on the form and the textbox has focus it is not working anymore...
I know that I could code this for every textbox too but can I not use this as main Form event which is overriding all other inputs?

Thanks a lot

1 Solution
Mike TomlinsonMiddle School Assistant TeacherCommented:
Set the KeyPreview property of the form to True.

SvenruttenAuthor Commented:
Thanks a lot

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now