Ok, what I have going on is a textbox that has been filled with some text depending on what was selected from a listbox.
say the textbox looks like this:
blah blah ??? as?f
what I need to figure out how to do is whenever the user clicks in the textbox and deletes a “?” character, I would like to replace that character with an * and then whenever they try to delete the * it will be replaced by a “?” , so that the end result will look something like
blah blah **? as*f
if they deleted all but one “?”.
No matter how long I have searched online I cannot seem to find anything similar.. the closest thing I have found is this question – Determine when and which character is added or deleted in a Text Box
But that doesnt really help for what I am trying to do.. if anyone has a good idea on where to start looking or even how to do it I would be very greatfull!
thanks in advance!
EDIT: Yes, this is for a Windows Form application, sorry i forgot to specify that. O.o
You can handle KeyDown event and bypass default handling. The event handler can look like the following:
You may also want to add checks for modifier keys, adjust cursor position, and implement custom behavior when text is selected, if needed.