locked
vb.net listview selected items (WM6) RRS feed

  • Question

  • in vb.net i have a listview set to list as viewtype. I have enabled checkboxes for the items in that listbox.
    How can i get the index of all selected items??
    Wednesday, March 25, 2009 12:23 AM

Answers

  • Hi,

    You could use the following code snippet to get the checked items from a listview control :-

    ListView.ListViewItemCollection lvic = this.listView1.Items;  
     
    List<ListViewItem> checkedItems = new List<ListViewItem>();  
     
    foreach (ListViewItem lvi in lvic)  
    {  
        if (lvi.Checked)  
        {  
            checkedItems.Add(lvi);  
        }  

    Dim lvic As ListView.ListViewItemCollection = Me.listView1.Items   
     
    Dim checkedItems As New List(Of ListViewItem)()   
     
    For Each lvi As ListViewItem In lvic   
        If lvi.Checked Then   
            checkedItems.Add(lvi)   
        End If   
    Next 

    Hope this helps.

    Paul Diston
    http://www.smartmobiledevice.co.uk/
    • Marked as answer by eagle00789 Wednesday, March 25, 2009 3:50 PM
    Wednesday, March 25, 2009 8:15 AM