private static int GetLineForRtf(RichTextBox rtf) { int index = rtf.SelectionStart; return rtf.GetLineFromCharIndex(index); }