C# richTextBox控制最大行数
private void m_txtComment_TextChanged(object sender, EventArgs e)
{
int lines = m_txtComment.GetLineFromCharIndex(m_txtComment.Text.Length - 1); //m_txtComment.Lines.Length; //行数
if(lines > maxLine - 1)
{
//第6行第一个字的位置
int my_index = m_txtComment.GetFirstCharIndexFromLine(maxLine);
//只保留前五行
m_txtComment.Text = m_txtComment.Text.Substring(0, my_index - 1);
}
m_ri.CommentContent.Content = m_txtComment.Text;
m_txtComment.Select(m_txtComment.Text.Length, 0);
}