[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 336
  • Last Modified:

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!
0
tunhien
Asked:
tunhien
  • 5
  • 4
1 Solution
 
topdog770Commented:
Look at the TextChanged event
0
 
tunhienAuthor Commented:
But how can I knew that is the event from a paste event?
0
 
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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
 
anyoneisCommented:
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
 
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now