[RESOLVED] [2005] Capture when a user pastes
:mad: I'm trying to find the easiest way to capture when the user presses CRTL+V or right clicks and pastes inside my textbox (txtSerial).
My end goal is to take the pasted text and turn it into an array, which I'm already doing, but the problem is my method takes the clipboard text when the user raises the TextChange event, even if their not actually pasting.
Edit:
Okay so I figured out how to capture the key press of CRTL + V, now I just need to figure out how to capture when the user pastes from right clicking.
Code:
Private Sub txtSerial1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtSerial1.KeyDown
If e.KeyCode = Keys.V And Keys.Alt Then
'Fire!
End If
End Sub
Re: [2005] Capture when a user pastes
Re: [2005] Capture when a user pastes
Quote:
Originally Posted by stimbo
That pastes the text into the textbox, I'm trying to capture the event of pasting, as in when the user does paste, I can do an If/Else statement, not to actually paste the code into the textbox, at least not right away.
Re: [2005] Capture when a user pastes
I think that with a tiny modification to the example you could tell it not to paste... or at least make it look like it hasn't.
Re: [2005] Capture when a user pastes
You'd have to inherit the TextBox class and override the WndProc method, then trap the appropriate message(s). Exactly what message(s) you'd be looking for I don't know, but there's where you start researching.
Re: [2005] Capture when a user pastes
I solved my problem by adding a context menu strip to the textbox and just adding an event to that button item for Paste. It's a cheap solution.