本文介绍了如何使用for循环基于其他listview值更改listview值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有这2个listview listView1有6个名为a,b,c,d,e,f的列,然后listView2有2个名为a,b的列

因此,例如. listview2行0列a具有"Joshua",而listview1具有"Joshua","ex","ex","ex"等.

计划是检查listView1是否存在包含listView2列a值的行.如果值相等,则listView2列b必须显示不完整",但是,如果listView2不包含listView1中的任何值,则listView2列b必须显示"Complete".

我尝试过的事情:

我有这段代码,它可以正常工作,但是无论我如何更改并尝试捕获所需的值,它都仍然在listView2列b中显示"Incomplete".

So I have this 2 listview listView1 has 6 columns named a,b,c,d,e,f then listView2 has 2 columns named a,b

so for example. listview2 row 0 column a has "Joshua" and listview1 has "Joshua", "ex","ex"","ex" and so on.

the plan is to check listView1 if there is/are rows that contains listView2 column a values. if there are equal values listView2 column b must show "Incomplete", however if listView2 doesnt contain any value from listView1, listView2 column b must show "Complete".

What I have tried:

I have this code, it is working but no matter how I change and attempt to trap the value I want, it still displays "Incomplete" in listView2 column b.

for(int re = 0; re < listView1.Items.Count; re++)
            {
                Orders frm = new Orders(this);
                l1[re] = listView1.Items[re].SubItems[2].Text;
                for (int er = 0; er < listView2.Items.Count; er++)
                {

                    l2[er] = listView2.Items[er].SubItems[0].Text;
                    if ((l1[re] != l2[er] || listView1.Items.Count == 0) && checking == "noblanked")
                    {
                        listView2.Items[er].SubItems[1].Text = "Complete";
                    }
                    if (l1[re].Contains(l2[er]) || checking == "blanked")
                    {
                        listView2.Items[er].SubItems[1].Text = "Incomplete";
                    }
                    listView2.Items[er].SubItems[1].Text = listView2.Items[er].SubItems[1].Text;
                }
            }

推荐答案

listView2.Items[er].SubItems[1].Text = listView2.Items[er].SubItems[1].Text;


这篇关于如何使用for循环基于其他listview值更改listview值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 22:45