当前位置:网站首页>C RichTextBox controls the maximum number of rows

C RichTextBox controls the maximum number of rows

2022-06-23 07:58: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; // Row number 
            if(lines > maxLine - 1)
            {
    
                // The first 6 Position of the first word of the line 
                int my_index = m_txtComment.GetFirstCharIndexFromLine(maxLine);
                // Keep only the first five lines 
                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://yzsam.com/2022/174/202206230729015997.html