Print Line Numbers in Label from RichTextBox


Here is an example of getting line numbers in Label from RichtextBox.

First Take one richtextbox and a label on the form.

then double click on the richtextbox and it will generate richTextBox1_TextChanged event and write the
following code.
private
void richTextBox1_TextChanged(object sender, EventArgs e)
{
int i = richTextBox1.SelectionStart;
label1.Text = "Line Number::" + richTextBox1.GetLineFromCharIndex(i);
}