Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# - Update a subitem within a listview

I am working on an application where users enter information that is then added to a listview. That works great. The only problem is, the application connects to a web site that updates the "Points" field in that listview for each account. I am not sure how I can update a single subitem within a listview.

Here is an example screenshot:

alt text

How can I select a specific subitem in a specific row to update?

like image 577
user Avatar asked Oct 26 '09 00:10

user


1 Answers

Ok, I'm going to assume Windows Forms.

WinForms' ListViewItem class has a Name property, which you can use to look up a specific item in a list. So as you populate the list, assign a unique value to the Name of each:

var item = new ListViewItem("Text");
item.Name = "foo"; // some unique id string
listView1.Items.Add(item);

That way you can locate the item in the ListView later, using its Items.Find method.

var fooItem = listView1.Items.Find("foo", false);
like image 113
Matt Hamilton Avatar answered Sep 24 '22 00:09

Matt Hamilton