2019年8月3日 星期六

[C#] TextBox or RichTextBox

TextBox和RichTextBox皆適用

1.Change text color in text box 


           




richTextBox1.SelectionColor = Color.Red;
richTextBox1.AppendText("0123456789");


3.修改字串中的字體顏色





            


richTextBox1.AppendText("0123456789");
richTextBox1.Select(3, 2);
richTextBox1.SelectionColor = Color.Red;


(3.測試中...)




richTextBox1.AppendText("0123456789");
            richTextBox1.Select(1, 2);          
            Font oldFont = richTextBox1.SelectionFont;
            richTextBox1.SelectionFont = new Font(oldFont, FontStyle.Bold);
            richTextBox1.AppendText("\r\naaa");



2.自動滾動到最下面(自動滾動到文字新增處)
/*Scroll to the bottom of the page*/
textBox1.SelectionStart = textBox1.Text.Length;
textBox1.ScrollToCaret();







參考資料:
https://zhidao.baidu.com/question/77745216.html







[C#] .bin檔存取及讀寫

●Read Bin file