Hello, guys!
I have a problem with a richtextbox. I would like to select a line in a rtb by clicking on a line... I don't know the number of the line, I need to get it's number by clicking... If you have any idea, please help me.
Thx a lot.
How to select a line by clicking in a RichTextBox?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

piyush sardhara177 reputationPosted Apr 9, 2011, 1:46 AM EDT
private void richTextBox1_MouseClick(object sender, MouseEventArgs e)
{
int firstcharindex = richTextBox1.GetFirstCharIndexOfCurrentLine();
int currentline = richTextBox1.GetLineFromCharIndex(firstcharindex);
string currentlinetext = richTextBox1.Lines[currentline];
richTextBox1.Select(firstcharindex, currentlinetext.Length);
}