can i make this loop continue in such a way that after last item in listbox to go to the first one and so on…
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);
}
}
}
}
Any help would be greatly appreciated!
Thank you for all the answers
it seems that my list was going backwads so i must replace
for (int i = listBox1.Items.Count - 1; i >= 0; i--)
with
for (int i=0;i<ListBox1.Items.Count;i++)
Something like this ?