C # RichTextBox automatic pull-down to the last method

Source: Internet
Author: User

C # RichTextBox automatically scrolls to the last cursor until the last line is automatically displayed

private void Richtextbox1_textchanged (object sender, EventArgs e)
{
Richtextbox1.selectionstart = Richtextbox1.textlength;

//Scrolls the contents of the control to the current caret position.
Richtextbox1.scrolltocaret (); Caret meaning: caret; insert symbol; (^)

}

Other:

  rtxt.AppendText(message+ "\n" );   rtxt.Select(rtxt.Text.Length, 0);   rtxt.ScrollToCaret();C # RichTextBox garbled after reading txt Chinese.

Use the RichTextBox mechanism to generate RTF document content, and then pass in rich Text format content to the control

Http://www.cnblogs.com/wuhuacong/archive/2010/07/20/1781378.html

Or when reading the contents of the file, add the encoding

encoding.default);          String strline = Sr. ReadLine ();          StringBuilder sb = new StringBuilder ();          while (strline! = null)          {            strline = Sr. ReadLine ();            SB = sb. Append (strline + "\ n");          }          Sr. Close ();          richTextBox1.Text = sb. ToString ();
Other Answer 1:
       StreamReader sr = new StreamReader (FS, System.Text.Encoding.UTF8);//test succeeded
Other Answer 2:
StreamReader sr = new StreamReader (FS, System.Text.Encoding.Default);
Change to try
StreamWriter SW = new StreamWriter (FS, System.Text.Encoding.GetEncoding ("GB2312"));

C # RichTextBox automatic pull-down to the last method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.