How to get the current line in a RichTextBox control?
Say I clicked somewhere inside a RichTextBox control. How can I get the current line the caret is currently on? Btw this is to retrieve the whole text string of that line. That's what RichTextBox.GetLineFromCharIndex() does. Pass the SelectionStart property value. This worked for me: this.WordWrap = false; int cursorPosition = this.SelectionStart; int lineIndex = this.GetLineFromCharIndex(cursorPosition); string lineText = this.Lines[lineIndex]; this.WordWrap = true; One way is to send it the EM_LINEFROMCHAR Message . I'm sure there are other ways. user718424 If you want to get current Line