Winform編程中,使用的Textbox控件,我們很有可能會遇到需要隨時更新其內容(比如聊天窗口文字的更新),當內容過多的時候,就會出現滾動條,如何讓滾動條時刻跟隨內容的最下面內容呢?
1. 在[設計模式]裏雙擊TextBox,添加TextChanged事件:
2. 在相應的cs文件中填入下面的code:
相關鏈接:http://blog.sina.com.cn/s/blog_4cb9953f0100c7wg.html
Winform編程中,使用的Textbox控件,我們很有可能會遇到需要隨時更新其內容(比如聊天窗口文字的更新),當內容過多的時候,就會出現滾動條,如何讓滾動條時刻跟隨內容的最下面內容呢?
1. 在[設計模式]裏雙擊TextBox,添加TextChanged事件:
2. 在相應的cs文件中填入下面的code:
相關鏈接:http://blog.sina.com.cn/s/blog_4cb9953f0100c7wg.html
this.richTextBox2.SelectionStart=this.richTextBox2.Text.Length; this.richTextBox2.ScrollToCaret();
public partial class MyMessageBox : Window { public static void Show(string strErrorInfo) {