如何在C中的TextBox中获取光标的列号

我有一个多行文本框,我想在表单上有一个标签,显示当前行和列的位置,就像 Visual Studio 所做的那样。

我知道我可以接电话

请先 登录 后评论
本文连接: http://www.china-sunrider.com.cn/question/7831
source: https://stackoverflow.com/questions

3 个回答

Joel Coehoorn

在我的脑海中,我认为您想要 SelectionStart 属性。

请先 登录 后评论
Omer van Kloeten
textBox.SelectionStart -
textBox.GetFirstCharIndexFromLine(textBox.GetLineFromCharIndex(textBox.SelectionStart))
请先 登录 后评论
DamienG
int line = textbox.GetLineFromCharIndex(textbox.SelectionStart);
int column = textbox.SelectionStart - textbox.GetFirstCharIndexFromLine(line);
请先 登录 后评论
  • 5 关注
  • 0 收藏,273 浏览
  • RyanE 提出于 2022-09-27 05:32
user contributions licensed under CC BY-SA.