1

Hi, i am using VB6 and in my project using List View Control. The checkboxes property is setted true. Now i want to implement a functionality so that to remove only those entries/items cheked by user from the list. Can anybody tell me how to implement this. ANY CODE

7
Contributors
11
Replies
21
Views
9 Years
Discussion Span
Last Post by __avd
Featured Replies
  • 1
    __avd 1,826   7 Years Ago

    We appreciate your help. Have you ever noticed that the current thread is two years old? Please do not resurrect old threads and have a look at forum [URL="http://www.daniweb.com/forums/faq.php?faq=daniweb_policies"]rules[/URL]. Please read before posting - [url]http://www.daniweb.com/forums/thread78223.html[/url] Thread Closed. Read More

0

Hi,

Loop thru all the List Items and if it is selected use this code to delete the item:

lvw.ListItems.Remove (2)

Above code removes second item in listview.

Regards
Veena

0

Thanx for your quick reply, but i am recieveing an error :
" Run-time error '35600';
Index out of bounds"

The code is :
Dim nI As Integer

For nI = 1 To lvBooks.ListItems.Count
If lvBooks.ListItems.Item(nI).Checked = True Then
lvBooks.ListItems.Remove (nI)
End If
Next nI

0

Hi,

This is a Tricky Situation,

Since After Removing Selected Items, ListItems.Count Keeps on Decreasing, so u have to reverse ur "For Loop " condition.
Check this Code:

For nI = lvBooks.ListItems.Count To 1 Step -1
    If lvBooks.ListItems.Item(nI).Checked = True Then
         lvBooks.ListItems.Remove (nI)
    End If
    If lvBooks.ListItems.Count=0 Then Exit For
Next nI

Regards
Veena

0

Hi, last year i asked this question and answered well. No i am in the same situation in VB.NET. What is to do same thing means removing checked items from list view in VB.NET

0

Hi, i am using VB6 and in my project using List View Control. The checkboxes property is setted true. Now i want to implement a functionality so that to remove only those entries/items cheked by user from the list. Can anybody tell me how to implement this.

Edited by happygeek: fixed formatting

0

Hi,

Try this code for VB.Net :

For Each lvItem As ListViewItem In ListView1.Items
    If lvItem.Checked Then
        lvItem.Remove()
    End If
Next

Regards
Veena

0

Thanx for your quick reply, but i am recieveing an error :
" Run-time error '35600';
Index out of bounds"

The code is :
Dim nI As Integer

For nI = 1 To lvBooks.ListItems.Count
If lvBooks.ListItems.Item(nI).Checked = True Then
lvBooks.ListItems.Remove (nI)
End If
Next nI

Thanxxxxx

0

Here is my code...

Dim lvi As ListItem
    Dim i As Integer
    Dim count As Integer
    
    count = ListView1.ListItems.count
    
    For i = 1 To count
    
        If i > count Then Exit For
        
        Set lvi = ListView1.ListItems(i)
    
        If lvi.Checked = True Then
                                              
            ListView1.ListItems.Remove (lvi.Index)
            i = i - 1
            count = count - 1
            
        End If
    Next
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.