C# richtextbox 自动滚动到最后 光标到最后 自动显示最后一行
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意思:脱字符号;插入符号; (^)
}
其他:
rtxt.AppendText(message+
"
"
);
rtxt.Select(rtxt.Text.Length, 0);
rtxt.ScrollToCaret();
C# RichTextBox读取txt中文后出现乱码。
利用RichTextBox的机制来生成RTF文档内容,然后传入RTF格式内容给控件
http://www.cnblogs.com/wuhuacong/archive/2010/07/20/1781378.html
或在读取文件内容时加上编码
StreamReader sr = new StreamReader(fs, Encoding.Default); string strline = sr.ReadLine(); StringBuilder sb = new StringBuilder(); while (strline != null) { strline = sr.ReadLine(); sb = sb.Append(strline + " "); } sr.Close(); richTextBox1.Text = sb.ToString();
其他回答1:
StreamReader sr = new StreamReader(fs, System.Text.Encoding.UTF8);//测试成功
其他回答2:
StreamReader sr = new StreamReader(fs, System.Text.Encoding.Default);
改成 试试
StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.GetEncoding("GB2312"));
转载于:https://www.cnblogs.com/watermarks/p/8459254.html