I’m currently in a .NET4 Windows Forms Application.
I’m trying to make something like intellisense, but very very basic.
Lets say the user is focusing a RichTextBox, and typing something like:
Search. After this specific phrase I want it to ‘auto fill’ like so: Search "" and place the caret in between the ” “.
That way when the user keeps typing the caret stays in between the ” ” like this:
Search "[usertypinghere][caretposition]"
I’m not sure how to get the current position of the caret, let alone how to keep it there.
It’s
SelectionStartThe joy is it’s part of TextBoxBase so you can have it inTextBox,RichTextBox,MaskedTextBox, or even other’s custom derivative. You’ll want to subscribe forTextChangedevent to watch for “Search”, then set theSelectionStartthere after autofill, then subscribe forSelectionChangedEventfor keeping theSelectionStartfrom veering off.Oh, and if you got several keywords, you’ll want to combine those keyword in sort of
DictionaryofTuplesto generalize the methods.EDIT
My test code. No flicker, no overriding controls. Just plain event subscriber