I’m trying to build a simple HTML text editor in a Windows Form application. I would like to be able to programmatically detect where the text cursor is at a particular moment so I can insert text programmatically at that point.
I would have thought this was an obvious thing, like a property that gets or sets the current text cursor position, but I haven’t found one! So how do I find out where that cursor is?
Use the
TextBox.SelectionStartproperty. The caret index starts at 0 for the left-most position.