I want to prevent one particular character * (asterisk) from being entered or pasted into a text box.
I tried:
key_pressevent – but it does not handle the case when user pastes an asterisk to the text box.text_changedevent – but when I remove the character, the cursor position goes back to the beginning of the text.
So I am wondering how to handle it, preferably in one event.
use the text changed event, but save the location of the cursor (the SelectionStart and SelectionEnd properties) before you remove the asterisk, then re set the cursor position (less the number of asterisks removed before the cursor).