开发者

Find the difference (text)

开发者 https://www.devze.com 2023-04-02 03:35 出处:网络
I need a way to run a sub every time that text is added to a richtextbox.There is a changed event, but I have to know exactly what was added and at what position (even as trivial as a single space).I

I need a way to run a sub every time that text is added to a richtextbox. There is a changed event, but I have to know exactly what was added and at what position (even as trivial as a single space). I was going to do 'onKeyUp' but if users press CTRL + V, instead of getting the inserted content, I'll end up with just a 'v'.

开发者_运维百科

Is there a way to do this? I need to be able to get the position that the content was added at and what was added. I'm doing this in VB.net.

I want to basically do something similar to http://typewith.me/

Let me show an example of what I want:

TEXT 1:

This is a message, currently no changes have been performed.

TEXT 2:

This is a message, currently none changes have been performed.

OUTPUT:

'ne' added at index position 31.

Cheers!


This might not be the most elegant solution, but the first thing that springs to mind is to store the contents of the text box in a variable. Every time it's changed, check the new contents of the text box against the stored contents and do whatever you need to, then store it again. This handles typing, pasting, deleting, etc.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号