我可以让这个循环以这样的方式继续,在列表框中的最后一个项目之后转到第一个等等......
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker worker = sender as BackgroundWorker;
for (int i = listBox1.Items.Count - 1; i >= 0; i--)
{
{
if (worker.CancellationPending == true)
{
e.Cancel = true;
break;
}
else
{
string queryhere = listBox1.Items[i].ToString();
this.SetTextappend("" + queryhere + "\n");
System.Threading.Thread.Sleep(500);
worker.ReportProgress(i * 1);
}
}
}
}
任何帮助将不胜感激!
谢谢你的所有答案
看来我的清单倒退了,所以我必须更换
for (int i = listBox1.Items.Count - 1; i >= 0; i--)
和
for (int i=0;i<ListBox1.Items.Count;i++)