日期:2014-05-18 浏览次数:22570 次
public partial class Form1 : Form
{
string[] arrName = new string[7]{"aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg"};
public Form1()
{
InitializeComponent();
textBox1.Text = "";//多行
}
private void button1_Click(object sender, EventArgs e)
{
//每隔一秒textBox1增加一行(各行为数组的各元素)
//textBox1上当前行显示最后追加的一行。
}
private void button2_Click(object sender, EventArgs e)
{
//停止增加
}
}
Timer timer = new Timer();
timer1.Interval = 1000;
private void button1_Click(object sender, EventArgs e)
{
//每隔一秒textBox1增加一行(各行为数组的各元素)
timer.Start();
//textBox1上当前行显示最后追加的一行。
textBox1.AppendText(".........")
textBox1.AppendText("\r\n");
}
private void button2_Click(object sender, EventArgs e)
{
//停止增加
timer1.Stop();
}
------解决方案--------------------
2,5楼代码不错
学习了!
------解决方案--------------------
使用TextBoxBase.ScrollToCaret 方法 可以自动的定位于当前的光标点。
当添加一行的时候光标认在最后。如果不确定的话,可以使用TextBoxBase.SelectionStart 属性设置到TextBoxBase.SelectionLength 属性的位置。然后再调用ScrollToCaret 方法。
------解决方案--------------------
用Timer 控件 或 线程
------解决方案--------------------
用timer事件