C# - 一个列表视图中更新一个子项 [英] 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.
下面是一个例子截图:
我怎样才能在特定的行选择特定的子项更新?
How can I select a specific subitem in a specific row to update?
推荐答案
好吧,我将承担Windows窗体。
Ok, I'm going to assume Windows Forms.
的WinForms'的ListViewItem类有一个名称属性,它可以用来查找特定项目在列表中。所以,当你填充列表,一个独特的价值分配给每个的名称:
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);
这样,你就可以在以后定位在ListView的项目,使用它的<一个href=\"http://msdn.microsoft.com/en-us/library/system.windows.forms.listview.listviewitemcollection.find.aspx\"相对=nofollow> Items.Find 方法。
var fooItem = listView1.Items.Find("foo", false);
这篇关于C# - 一个列表视图中更新一个子项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!