我有一个多行文本框,我想在表单上有一个标签,显示当前行和列的位置,就像 Visual Studio 所做的那样。
我知道我可以接电话
在我的脑海中,我认为您想要 SelectionStart 属性。
textBox.SelectionStart - textBox.GetFirstCharIndexFromLine(textBox.GetLineFromCharIndex(textBox.SelectionStart))
int line = textbox.GetLineFromCharIndex(textbox.SelectionStart); int column = textbox.SelectionStart - textbox.GetFirstCharIndexFromLine(line);