All you have to use is RichTextBox.GetLineFromCharIndex method.
You will find more detailed explanation here:
GetLineFromCharIndex[^]
Here is complete example of counting total number of lines in RTB
int lineNumber = richTextBox1.GetLineFromCharIndex(richTextBox1.TextLength) + 1; MessageBox.Show(lineNumber.ToString());This 2 lines of code will give you number of lines in RichTextBox
You will find more detailed explanation here:
GetLineFromCharIndex[^]
Here is complete example of counting total number of lines in RTB

