using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO; namespace texttest
{
public partial class Form1 : Form
{
List <string> alist = new List <string>();
int times = 0;
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
times = 0;
alist.Clear();
string line;
StreamReader sr = new StreamReader("a.txt", Encoding.Default);
while ((line = sr.ReadLine()) != null)
{
alist.Add(line);
}
timer1.Interval = 1000;
timer1.Enabled = true; } private void timer1_Tick(object sender, EventArgs e)
{
readline();
}
private void readline()
{
richTextBox1.Text += alist[0] + "\r\n";
alist.Remove(alist[0]);
times++;
if (times == 2)
{
timer1.Enabled =false ;
MessageBox.Show("输出第二行暂停,点击button2继续");
}
if (alist.Count == 0)
timer1.Enabled = false; } private void button2_Click(object sender, EventArgs e)
{
timer1.Enabled = true;
} private void Form1_Load(object sender, EventArgs e)
{
string line;
StreamReader sr = new StreamReader("a.txt", Encoding.Default);
while ((line = sr.ReadLine()) != null)
{
alist.Add(line);
}
} }
}
如果想在timer完成后,即在显示完最后一行后弹出另一个窗体,应该怎么写?本人菜鸟....
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO; namespace texttest
{
public partial class Form1 : Form
{
List <string> alist = new List <string>();
int times = 0;
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
times = 0;
alist.Clear();
string line;
StreamReader sr = new StreamReader("a.txt", Encoding.Default);
while ((line = sr.ReadLine()) != null)
{
alist.Add(line);
}
timer1.Interval = 1000;
timer1.Enabled = true; } private void timer1_Tick(object sender, EventArgs e)
{
readline();
}
private void readline()
{
richTextBox1.Text += alist[0] + "\r\n";
alist.Remove(alist[0]);
times++;
if (times == 2)
{
timer1.Enabled =false ;
MessageBox.Show("输出第二行暂停,点击button2继续");
}
if (alist.Count == 0)
timer1.Enabled = false; } private void button2_Click(object sender, EventArgs e)
{
timer1.Enabled = true;
} private void Form1_Load(object sender, EventArgs e)
{
string line;
StreamReader sr = new StreamReader("a.txt", Encoding.Default);
while ((line = sr.ReadLine()) != null)
{
alist.Add(line);
}
} }
}
如果想在timer完成后,即在显示完最后一行后弹出另一个窗体,应该怎么写?本人菜鸟....
{
richTextBox1.Text += alist[0] + "\r\n";
alist.Remove(alist[0]);
times++;
if (times == 2)
{
timer1.Enabled =false ;
MessageBox.Show("输出第二行暂停,点击button2继续");
}
if (alist.Count == 0)
{
Form2 frm=new Form2();
frm.ShowDialog(this);}
}
你先试试,我没有工具调试。