[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 472
  • Last Modified:

Ctrl+X, Ctrl+V, Ctrl+C or Cut, Copy, Paste using the keyboard -> What are their keycode or keychar?

The title says all. For example, what is the keychar or keycode of Ctrl+X. Thank you.
0
maidinhtai
Asked:
maidinhtai
  • 4
  • 2
  • 2
  • +1
2 Solutions
 
PockyMasterCommented:
try the following in the keydown event  

If e.Control And e.KeyCode = Keys.X Then

        End If
0
 
maidinhtaiAuthor Commented:
Hi PockyMaster. This is a clear example:
----------------------------------------
Private Sub TextBox1_PreviewKeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) Handles TextBox1.PreviewKeyDown
         If e.Control And e.KeyCode = Keys.V Then
             'Do nothing
    End Sub
-----------------------------------------
What I need is when the user press Ctrl+V, nothing will happen. That means the text in Clipboard is not pasted into textbox1.
0
 
Bob LearnedCommented:
e.KeyCode = Keys.None

   or

e.IsInputKey = False

Bob
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
appariCommented:
you have to do it in Keydown event

    Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
        If e.Control And e.KeyCode = Keys.V Then
            e.SuppressKeyPress = True
            e.Handled = True
        End If
    End Sub
0
 
PockyMasterCommented:
Yeah, like I said before, use the keydown event
0
 
maidinhtaiAuthor Commented:
TheLearnedOne, where can I put wher
0
 
maidinhtaiAuthor Commented:
TheLearnedOne, where can I put "e.KeyCode = Keys.None" or "e.IsInputKey = False"? If I put it to KeyDown event, so appri's answer is OK.
0
 
Bob LearnedCommented:
In PreviewKeyDown, but appari's answer will work, too.

Bob
0
 
maidinhtaiAuthor Commented:
In the Subroutine that handles  the PreViewKeyDown event, e.KeyCode is readonly, and e.IsInputKey = False seems useless (I mean it does nothing at all). I try changing e.IsInputKey = False to e.IsInputKey = True but there nothing different, too.
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!

  • 4
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now