且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在文本框中找出光标位置

更新时间:2022-12-20 10:34:35

如果它是多行文本框,则此代码将有所帮助:

If it is a multiline textbox, this code will help:

int line = textBox1.GetLineFromCharIndex(textBox1.SelectionStart) + 1;
int col = textBox1.SelectionStart - textBox1.GetFirstCharIndexOfCurrentLine();