C# .NET - count list view rows - Asked By Priyanka on 09-Jun-13 02:17 PM

i want to count rows in list view where 3rd column value is 'Check'. If listview contains only one row then message box should be shown "only one row exists".
Hemanth Kumar replied to Priyanka on 10-Jun-13 01:52 AM
Hi Dvorkin ,

 You can search the Listview Items as given below
foreach (ListViewItem lvi in listView.Items)
       if (lvi.SubItems[2].Text == saLvwItem[2])
         // item already in list
         // increase the ItemNumber
         lvi.SubItems[1].Text = (Convert.ToInt32(lvi.SubItems[1].Text) + Convert.ToInt32(saLvwItem[1])).ToString();
         bFound = true;