Wednesday, 20 November 2013

How to get Listview subitems index

if (listview1.SelectedItems.Count > 0)
{
                int icolcount = 0; string  sID = "";
                foreach (ColumnHeader header in listview1.Columns)
                {  
                    if (header.Text.ToLower().Trim() == "id")
                    {
                        sID= listview1.SelectedItems[0].SubItems[icolcount].Text;
                        break;
                    }
                    icolcount ++;
                }
}

No comments:

Post a Comment