当前位置:网站首页>C# richTextBox控制最大行数

C# richTextBox控制最大行数

2022-06-23 07:29:00 pcjiushizhu

 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);

        }
原网站

版权声明
本文为[pcjiushizhu]所创,转载请带上原文链接,感谢
https://blog.csdn.net/pcjiushizhu/article/details/111425144