I would like to modify the default behavior of a regular WinForms C# textbox control so that pressing backspace deletes whole words instead of just a single character.
Ideally I would like to have this special behavior only when the caret position is in-front of a white-space character. For example; pressing backspace one time when the caret is at “hello world|” should still only remove one character resulting in “hello worl|” – but if the caret is at “hello world |” when I press backspace, then the result should be “hello |”
First you need to add
KeyEventHandlerforKeyDownevent for yourTextBoxAfter that you can handle the event like this: