C# C语言中ListViewItem中的双项陷阱#

C# C语言中ListViewItem中的双项陷阱#,c#,.net,winforms,listviewitem,C#,.net,Winforms,Listviewitem,我试着想办法解决这个问题。他们都不是为我工作的 我试图以他的源代码为基础,但我对他的陷阱感到困惑。 我将他的源代码用于我的项目 ListViewItem item = ListView1.FindItemWithText(txtPLU.Text); if (item != null) { MessageBox.Show("Item is already been exist!"); //Result if the item has exist in the listview item.

我试着想办法解决这个问题。他们都不是为我工作的

我试图以他的源代码为基础,但我对他的陷阱感到困惑。 我将他的源代码用于我的项目

ListViewItem item = ListView1.FindItemWithText(txtPLU.Text);
if (item != null)
{
    MessageBox.Show("Item is already been exist!"); //Result if the item has exist in the listview item.
}
else
{
    addToList(); //Its a method to add the product items in the ListViewItem.
    txtBoxPLU.Focus();
}
运行时的行为是只添加一个项

对不起,如果这对你们大家来说有点困惑。我只想捕获listview项中是否已经存在该项。

有两种方法可用于查找集合中是否包含项

方法和步骤

例如:


我的问题是,如果listviewitem上的项目存在,我将如何捕获该项目?
ListViewItem _item = new ListViewItem();

if (!listView1.Items.Contains(_item))
{
    // TODO: Add to list.
}
else
{
    // Already exists.
}