|
-
Mar 21st, 2007, 03:17 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] [2005] Capture when a user pastes
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
Last edited by tylerm; Mar 21st, 2007 at 03:24 PM.
-
Mar 21st, 2007, 03:40 PM
#2
Re: [2005] Capture when a user pastes
-
Mar 21st, 2007, 04:48 PM
#3
Thread Starter
Hyperactive Member
Re: [2005] Capture when a user pastes
 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.
-
Mar 21st, 2007, 04:55 PM
#4
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.
-
Mar 21st, 2007, 06:56 PM
#5
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.
-
Mar 21st, 2007, 07:26 PM
#6
Thread Starter
Hyperactive Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|