再问查询开启两个线程,结束后dataGridView滚动条失效
在查询数时,开启两个线程:一个是进度条循环递增,一个是数据查询。当数据查询结果显示在dataGridView控件里时,结束进度条线程。但奇怪的是,此时dataGridView控件的水平滚动条不能动,不知道为什么?
下面是主要代码:
private void button1_Click(object sender, EventArgs e)
{
this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
proBarThread = new Thread(new ThreadStart(SetToolStripProgressBar));
proBarThread.Start();
//开启进度条线程
reportThread = new Thread(new ThreadStart(DataSetTabPageTwo));
reportThread.IsBackground = true;//后台线程
reportThread.Start();
//开启数据查询线程
timer1.Enabled = true;
this.Cursor = System.Windows.Forms.Cursors.Default;
}
private void timer1_Tick(object sender, EventArgs e)
{
if (!reportThread.IsAlive) //线程结束
{
this.Cursor = System.Windows.Forms.Cursors.Default;
proBarThread.Abort();
proBarThread.Join();
proBarThread = null;
//
toolStripProgressBar1.Value = toolStripProgressBar1.Maximum;
Thread.Sleep(500);
toolStripProgressBar1.Visible = false;
//
timer1.Enabled = false;
}
}
------解决方案--------------------你的另一个线程结束了吗~!