catch copy and paste event from class interited from TextBox class!

I'm trying to catch event whenever people paste a string inside a textbox.

I wanna know what string is pasted and make some process with it!

My class is inherit from TextBox class!
So please so me how to solve it! :D
thanks!
tunhienAsked:
Who is Participating?
 
anyoneisConnect With a Mentor Commented:
OK. What about just handling the "TextChanged" event. Keep track of hat was in the text box last time you got the event, then compare to what is there to find the changes? That way, you don't care from where or how  the text is coming.

David
0
 
topdog770Commented:
Look at the TextChanged event
0
 
tunhienAuthor Commented:
But how can I knew that is the event from a paste event?
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
anyoneisCommented:
I'm pretty sure the functionality you are looking for is not there... There is no "OnPaste" event.

What are you using this for? Would it be better to give them a button that said something like "Use Clipboard" which would cause you to go get the text and then act on it?

David
0
 
tunhienAuthor Commented:
If there is no event onPaste! So how can I process the paste event!
Don't have to do it is just 1 event such as on_key_press!
But list some event relate to paste content!

Especailly while I use a mouse (right click and click paste!) I don't know how to catch it!

And How to capture the paste text!
0
 
anyoneisCommented:
I think you will get more help if you answer more questions:

1) What are you doing this for?

2) Are you sure that you want to use cut and paste? How about using drag and drop instead?

David
0
 
tunhienAuthor Commented:
OK! :D

1) I'm trying to get any words in the text box when people typing! And I did it well! But if they don't type, they copy & paste or drag and drop (as you told) I have to catch that text to analysis into words.

2) Thanks for remind me about drag & drop!

0
 
tunhienAuthor Commented:
Thanks!

Is there any good way to get the change of text without using a new variable to save the previous version?
Is TextBox control support us to do that?

Thanks again? :D
0
 
anyoneisCommented:
You could use the TextBox'es Tag property to store the prior contents. However, if you were going to use this technique in a lot of places, I would develop a custom "extender" control. Here is a reference by one of my "heroes", Dino Esposito:  

http://weblogs.asp.net/despos/archive/2003/12/11/42766.aspx

He is updating an article he wrote for MSDN years ago, which is here:

http://msdn.microsoft.com/msdnmag/issues/03/11/CuttingEdge/

David
0
 
tunhienAuthor Commented:
OK! Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.