|
-
Oct 1st, 2000, 11:24 PM
#1
Thread Starter
Junior Member
I wanna remove the selected item(s) from ListView1,but VB says "error" when useing the following codes:
-------------------------------------------------------------------------
Private Sub RemoveItems()
If ListView1.SelectedItem Is Nothing Then
Exit Sub
Else
Dim Counter As Long, lvwCount As Long
lvwCount = ListView1.ListItems.Count
For Counter = 1 To lvwCount
If ListView1.ListItems(Counter).Selected Then Exit For
Next Counter
ListView1.ListItems.Remove (Counter)
Call RemoveItems
End If
End Sub
----------------------------------------------------------------------------
When I all selected items moved from ListView1, I write the following code to debug:
Debug.Print ListView1.SelectedItem Is Nothing
And the output result IS NOT "True" ,It says "False".That is, the code " If ListView1.SelectedItem Is Nothing Then Exit Sub" is useless!
Can everyone tell me hao can I remove the selected item(s) from ListView1?
-
Oct 2nd, 2000, 02:25 AM
#2
Code:
Private Sub RemoveItems()
Dim Counter As Long, lvwCount As Long
lvwCount = ListView1.ListItems.Count
For Counter = lvwCount To 1 Step -1
If ListView1.ListItems(Counter).Selected Then
ListView1.ListItems.Remove (Counter)
End If
Next
End Sub
Good luck!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|