How do I get the removed character from a TextBox

T

Tony Johansson

Hello!

I have a TextBox and when I delete a character by using backspace is it then
possible to fetch this deleted character.
This deleted character could be any character in the TextBox.

//Tony
 
I

Ignacio Machin ( .NET/ C# MVP )

Hello!

I have a TextBox and when I delete a character by using backspace is it then
possible to fetch this deleted character.
This deleted character could be any character in the TextBox.

//Tony

You would have to keep track of the value before and after , you can
use KeyDown to get what the value was before, and then TextChanged
for the final value.
 
T

Tony Johansson

Hello!

Can you give just a small example so I understand what you mean.

//tony
 
P

Pavel Minaev

I have a TextBox and when I delete a character by using backspace is it then
possible to fetch this deleted character.
This deleted character could be any character in the TextBox.

Unless you have a textbox with very large amount of text (which is
dubious, since stock WinForms TextBox is limited to 64k), by far the
simplest thing you can do is handle TextChanged and compare the text
before and after. This is certainly going to be much more readable
than any attempts to hack KeyDown etc to detect the exact character.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top