本文介绍了如何在listview2中检查listview1项目是否不再存在并触发事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不认为我看到过这样的东西,我通过网搜索但是我能找到的只是使用foreach循环。







我想做的是如果listview1没有任何名为的项目Joshua,它会将listview2的Joshua从Incomplete改为Complete。



listview1可以有2个或更多Joshua,所以在所有Joshua消失之前,listview2必须保持不完整。当所有Joshua在Listview1中消失时,那就是当listview2的joshua为Complete时。







我把它放在timer1_tick中,因为listview1项目可以在时间到期时删除。(工作和完成工作,删除过期的listview项目)



我尝试过:



我用于循环,但它没有完全改变不完整。我想我可能在循环中错了。



这是我的代码

I dont think I saw something like this, i searched through net but all i could find is using foreach loop.

here I have the Listviews

What I wanted to do was If listview1 dont have any items named "Joshua", it will change listview2's "Joshua" from "Incomplete" to "Complete".

listview1 can have 2 or more "Joshua", so until all the "Joshua" are gone the listview2 must stay "Incomplete". when all the "Joshua" are gone in Listview1, thats when listview2's "joshua" be "Complete".

this must be the output.

I had put this in the timer1_tick since listview1 Items can be removed when time expires.(working and doing its job removing listview items that expires)

What I have tried:

I used for loop, but it doesnt change incomplete to complete. i think i might be wrong at the looping itself.

this is my code

for (int lst = 0; lst < listView2.Items.Count; lst++)
{
    for (int dgv = 0; dgv < dataGridView1.Rows.Count; dgv++)
    {
        if (listView2.Items[lst].SubItems[0].Text == listView1.Items[dgv].SubItems[0].Text )
        {
            continue;
        }
        else if (listView2.Items[lst].SubItems[0].Text != listView1.Items[dgv].SubItems[0].Text ) 
        {
            listView2.Items[lst].SubItems[1].Text = "Complete";
        }
    }
}

推荐答案


这篇关于如何在listview2中检查listview1项目是否不再存在并触发事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 04:58