假设我单击了 RichTextBox 控件内的某处。如何获取插入符号当前所在的当前行?
顺便说一句,这是检索该行的整个文本字符串。
最佳答案
这对我有用:
this.WordWrap = false;
int cursorPosition = this.SelectionStart;
int lineIndex = this.GetLineFromCharIndex(cursorPosition);
string lineText = this.Lines[lineIndex];
this.WordWrap = true;
关于c# - 如何获取 RichTextBox 控件中的当前行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2693984/