Trap Paste event

  • Thread starter Thread starter Matthew
  • Start date Start date
M

Matthew

When a user types Ctrl.+V in one form, I would like to trap the event and do
something else.
Is this possible?

Matthew
 
Set the form's KeyPreview property to true.

Enter the following event handler

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.Control And (e.KeyCode = Keys.V Or e.KeyCode = Keys.Insert)
Then
'Something pasted on the form.
End If
End Sub

Scott Swigart
blog - http://ea.3leaf.com
 
Set the form's KeyPreview property to true.
Enter the following event handler

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.Control And (e.KeyCode = Keys.V Or e.KeyCode = Keys.Insert)
Then
'Something pasted on the form.
End If
End Sub

That's it! Thank you, Scott.

Matthew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top