Skip to content

Get selected from listview

mirko gogic

Asked Jun 17, 2008, 2:04 PM EDT2 answers
Share
LinkedInX
I have a listview and i  added data using ListViewItem, i added tag text to all rows.

while (...)
                    {
                                           
                             ListViewItem item = new ListViewItem();
                             item.Tag = (Int64)data[0];
                             item.Text = (string)data[1];
                             item.SubItems.Add((string)data[2]);
                          
                             list.Items.Add(item);   
                        
                    }                   

Now i have a button the needs to remove items data form listview, but the problem is how to get tag values of selected rows ?

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Mahesh Chand
    0

     Something like this:

    ListView.SelectedListViewItemCollection items=
            this.ListView1.SelectedItems;
        
        foreach ( ListViewItem item in items)
        {
            string str = item.Tag;
        }

    0
  • 1 short reply
    • 0
      thx that was needed
      0