Solved

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

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

Thanks
0
Comment
Question by:FINDERSOL
4 Comments
 
LVL 14

Accepted Solution

by:
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
0
 
LVL 27

Expert Comment

by:planocz
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

0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB 2005 Tooltips on Form Load Event 15 34
VB.Net - TypeInitializer Error 25 32
Convert datetime to time string 10 28
how to hit button in form and close application from main() 4 22
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
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 (http://www.ecb.europa.eu/stats/exch…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

827 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