I've got a multiline textBox that I would like to have a label on the form displaying the current line and column position of, as Visual Studio does.
I know I can get the line # with GetLineFromCharIndex, but how can I get the column # on that line?
(I really want the Cursor Position on that line, not 'column', per se)
int line = textbox.GetLineFromCharIndex(textbox.SelectionStart);
int column = textbox.SelectionStart - textbox.GetFirstCharIndexFromLine(line);
textBox.SelectionStart -
textBox.GetFirstCharIndexFromLine(textBox.GetLineFromCharIndex(textBox.SelectionStart))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With