How do I tect a 'Ctrl'-'A' being pressed with a ListView control

Posted on 2008-06-26
Last Modified: 2008-08-15
As perthe question above (in VB .NET 2005)

Question by:FINDERSOL
LVL 14

Accepted Solution

rachitkohli earned 500 total points
ID: 21877800
On keydown event of ListView write

If (e.KeyCode = Keys.A And e.Modifiers = Keys.Control) Then
  MsgBox "Ctrl + A Pressed..!!"
End If
LVL 27

Expert Comment

ID: 21878298
If you want to check for any time the Ctrl -A is pressed you can use this in your form.

 Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean

        Const WM_KEYDOWN As Integer = &H100

        Const WM_SYSKEYDOWN As Integer = &H104

        If ((msg.Msg = WM_KEYDOWN) Or (msg.Msg = WM_SYSKEYDOWN)) Then

            Select Case (keyData)

                Case Keys.A To Keys.Z                                '<--- Catch the Keys you want

                    MessageBox.Show("You pressed " & ChrW(keyData))  '<--- Then do something

                Case Keys.Right

                    Me.Text = "Right Arrow Captured"

                Case Keys.Left

                    Me.Text = "Left Arrow Captured"

                Case Keys.Down

                    Me.Text = "Down Arrow Captured"

                Case Keys.Up

                    Me.Text = "Up Arrow Captured"

                Case Keys.Tab

                    Me.Text = "Tab Key Captured"

                Case (Keys.Control Or Keys.A)

                    Me.Text = "<CTRL> + A Captured"

                Case (Keys.Alt Or Keys.Z)

                    Me.Text = "<ALT> + Z Captured"

                Case Keys.NumPad0

                    Me.Text = "Num Pad '0' Captured"

                Case Keys.Delete

                    MessageBox.Show("Delete Captured")

                Case Keys.NumLock

            End Select

        End If

        Return MyBase.ProcessCmdKey(msg, keyData)

    End Function

Open in new window


Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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 (…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: (…

910 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

21 Experts available now in Live!

Get 1:1 Help Now