23,882
个编辑
更改
我的作品:文华
,无编辑摘要
string[] lines = { "hellow world", "nihao", "line3", "line4", "line5", "end" };
int currentLine = 0;
----
public Form1()
}
}
----
string[] lines;//所有文字,每行都有回车
int nextLine; //下一行
private void button2_Click(object sender, EventArgs e)
{
richTextBox1.Text =Resources.String1;
lines=richTextBox1.Lines;
richTextBox1.Text = "";
timer1.Interval = 1000;
timer1.Tick += new EventHandler(timer1_Tick);
timer1.Start();
}
void timer1_Tick(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder(richTextBox1.Text);
if (richTextBox1.Text != "")
{
sb.Append("\r\n");
}
sb.Append(lines[nextLine]); //添加下一行文字
richTextBox1.Text = sb.ToString();
richTextBox1.Select();
richTextBox1.SelectionStart = richTextBox1.Text.Length;
nextLine++;
if (nextLine >= lines.Length)
{
timer1.Enabled = false;
}
}