Clipboard Paste Event

vendiddy

Well-known member
Joined
May 14, 2006
Messages
64
Programming Experience
1-3
Is there a way of knowing when the user pastes some text into a textbox?

I want to be able to clean up and parse the text before letting it be pasted.

Thanks. :)
 
I want to detect the paste so I know when the user wants to paste something in the textbox. I don't want to mess with the clipboard if the user has copied some text without intending to paste it in my textbox.

Anyway, I did some searching and found some useful code in this Numeric TextBox example:
http://www.codeproject.com/useritems/NumericTextBox.asp

It detects when the user tries to paste non-numeric data into the textbox. There was a class in this program called TextBoxOnPaste.vb (I added this to my project). In my form_load, I added the code
VB.NET:
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] onPaste [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] TextBoxOnPaste(txtCourseName)[/SIZE]
I replaced his code in the TextBoxOnPaste class with my code ... and it works! :)
 

Attachments

  • TextBoxOnPaste.zip
    753 bytes · Views: 62
Ok, for your own applications paste operations listening to WM_PASTE message is clever. I thought you meant detecting this system wide in relation to your other question about creating a system utility that monitors clipboard.
 
Back
Top