In a Windows Form, using C#, how do I select (as in, actually highlight the text, making it accessible to the .SelectedText property) a word based on the cursor location?
Here’s what I’m trying to do. I have a textbox that users can currently select a word by highlighting it. They can then perform various actions to the word, but I want to make it simpler.
I wish to make it so they can simple put the cursor inside the word and the app will select the word the cursor is inside of.
Thanks in advance!
You can use
SelectionStartandSelectionLengthbut you probably need to find the next space from the cursor position, then reverse the contents of the textbox and find the next “space” from the “altered cursor” position, then use the two methods above.This will also work