I use Listviews in almost every project I do, and I edit a listview row by clicking on it, and then populating textboxs with the listview data.
The data is changed, in the textboxs as desired, and then the Save button updates the record in the backend database, clears out the listview, and reloads it.
Hack,
hi ya.i want to delete the listview selected listitem.when select the delete listview listitem to delete have error message come out "Index Out of Bound".
this is the current code:
Code:
Private Sub cmdDelete_Click()
Dim i As Integer
For i = 1 To ListView1.ListItems.Count
If (ListView1.ListItems(i).Checked = True) Then
ListView1.ListItems.Remove (i)
End If
Next i
End Sub
Thanks for help!
Last edited by gracehskuo; Dec 6th, 2007 at 02:05 AM.
ok,now i solved the index out of bounds error.but then i face another problem,i can delete all the selected lisitem to delete excepted the last row listview listitem cannot delete.please help i want all the selected listitem able to delete.
this is the current code:
Code:
Private Sub cmdDelete_Click()
Dim i As Integer
For i = 1 To ListView1.ListItems.Count - 1
If (ListView1.ListItems(i).Checked = True) Then
ListView1.ListItems.Remove (i)
End If
Next i
You don't need to adjust by -1 since ListItems collection is 1-based (first item at index 1) and not zero-based (eg. List() of ListBox, first item at ListIndex zero). And you have to iterate in reverse order because the indices shift (another listitem fills index 1 after listitem at index 1 is removed) after you remove an item from the collection.