PC Review


Reply
Thread Tools Rate Thread

How do I get the removed character from a TextBox

 
 
Tony Johansson
Guest
Posts: n/a
 
      20th Apr 2009
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


 
Reply With Quote
 
 
 
 
Ignacio Machin ( .NET/ C# MVP )
Guest
Posts: n/a
 
      20th Apr 2009
On Apr 20, 9:18*am, "Tony Johansson" <johansson.anders...@telia.com>
wrote:
> 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.
 
Reply With Quote
 
Tony Johansson
Guest
Posts: n/a
 
      20th Apr 2009
Hello!

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

//tony


"www.ghoz.net |" <Mahmoud Ghoz> skrev i meddelandet
news:(E-Mail Removed)...
> if you need that for undo ... you can use ctrl+z it is working by default.
> if not then you need to handle key down event, to know where the is the
> carret location location and save the char before the carret in case he
> strike backspace and the char after in case he strike delete
> Mahmoud Ghoz
> www.Ghoz.NET
>
>> 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
>>

>
>



 
Reply With Quote
 
Pavel Minaev
Guest
Posts: n/a
 
      20th Apr 2009
On Apr 20, 6:18*am, "Tony Johansson" <johansson.anders...@telia.com>
wrote:
> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
TAB character in TextBox The Last Danish Pastry Microsoft C# .NET 1 25th Jun 2008 12:09 PM
Character Set for TextBox Abra Microsoft C# .NET 2 3rd Feb 2006 12:50 PM
Take out last character from textbox or label tshad Microsoft ASP .NET 1 9th Jun 2005 11:05 PM
DateTimeFormatInfo Class Bug - Time Zone Offset has an illegal character- needs to be removed. Pure Krome Microsoft Dot NET Framework 0 10th Aug 2004 03:56 AM
how to put tab character into textbox? Vasant Nanavati Microsoft Excel Programming 7 11th Feb 2004 09:23 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:14 AM.