当没有while循环时,listView1.Items[0].SubItems.Add(DateTime.Now.ToString()) 就不出错;有while循环时就出错“集合已经达到其最大容量。”
我用的是visualstudio c#语言编写下面一段程序
当没有while循环时,listView1.Items[0].SubItems.Add(DateTime.Now.ToString()) 就不出错
有while循环时就出错“集合已经达到其最大容量。”
那位高手能帮忙解答一下?不胜感激!(循环语句是一定得用的)
while (isrun == 0)
{
if (listView1.Items.Count != 0)
{
listView1.Items[0].SubItems.Add(DateTime.Now.ToString());
listView1.Items[0].SubItems.Add("1");
if (Convert.ToInt32(listView1.Items[0].SubItems[1].Text) > timer1.Interval)
{
timer1.Start(); }
else
{
timer4.Interval = Convert.ToInt32(listView1.Items[0].SubItems[1].Text);
timer4.Start();
} }
}
当没有while循环时,listView1.Items[0].SubItems.Add(DateTime.Now.ToString()) 就不出错
有while循环时就出错“集合已经达到其最大容量。”
那位高手能帮忙解答一下?不胜感激!(循环语句是一定得用的)
while (isrun == 0)
{
if (listView1.Items.Count != 0)
{
listView1.Items[0].SubItems.Add(DateTime.Now.ToString());
listView1.Items[0].SubItems.Add("1");
if (Convert.ToInt32(listView1.Items[0].SubItems[1].Text) > timer1.Interval)
{
timer1.Start(); }
else
{
timer4.Interval = Convert.ToInt32(listView1.Items[0].SubItems[1].Text);
timer4.Start();
} }
}
isrun的值是什么啊
搞不好是死循环了。
问题出在isrun的值上
isrun = 1;
listView1.Items[0].Remove();
timer1.Enabled = false;
isrun = 0;
所以我需要不断地循环,判断一级队列是否为空,不空就移动记录。每次循环移动一条记录。