我有一个包含一些HashTables
的ArrayList
,我有一个ListView
包含一些项目。对数组列表匹配列表视图中的项目在C#
我需要的是将数组列表与列表项匹配。
如果一个项目在列表视图中而不在数组列表中,那么它应该从列表视图中移除。
如果不在列表视图或数组列表中,则将其添加到列表视图中。
这是一些代码:
ArrayList online_list = users;
foreach (Hashtable i in online_list)
{
ListViewItem item = new ListViewItem();
item.Text = (string)i["u_name"];
item.Name = (string)i["id"];
item.ImageIndex = 0;
lstvUsers.Items.Add(item);
}
该代码将所有的数组列表项目列表视图,而不检查!
你还在1.1或为什么你使用的ArrayList和哈希表? – 2012-07-09 22:07:59
我在3.5上使用它们,因为我从PHP web服务recive数据返回相关数组和阵列数组,所以我必须使用它们,如果你知道更好的解决方案指向它,但我仍然需要回答 – 2012-07-09 22:10:52