C#如何找到一个listview的某一项的值如何更改listview某一个项的值

来源:https://www.cnblogs.com/summary/p/4526671.html

 

用linq: 

ListViewItem li = ListViewUser.Items.Cast().First(x => x.Text == "1005" && x.SubItems["city"].Text == "北京");
string val = li.SubItems["city"].Text;

也可以是:   
 ListViewItem liv = listViewAlarm.Items.Cast().First(x => x.SubItems[0].Text == strID);          
            int index = liv.Index;
            listViewAlarm.Items[index].SubItems[1].Text = "something";  

 

你可能感兴趣的:(C#,备忘,随笔,winform)