How do I get the removed character from a TextBox

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
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
 
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.
 
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.
 
Back
Top