469,963 Members | 1,224 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,963 developers. It's quick & easy.

Delete image from listview

I have a program that capture images and put this into a listview (using imagelist), the problem is when I delete de image
the listview, when do that and capture another image, the image painting in the listview is the image delete, I supose
that the problem is that the image exist in the imagelist, in order to solve this problem I clear the imagelist and add all
the images captured, but i have another problem now, some time when I delete a image, when do IO.File.Delete(gstrPathImage & "\" & lstrFile) say that the file is be using with another process.

The code is:
Private Sub cmdDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDelete.Click
Dim lIndexes As ListView.SelectedIndexCollection = ListViewImages.SelectedIndices
Dim liIndex As Integer
Dim lstrFile As String

Dim liNumSelect As Integer = lIndexes.Count
Dim i, j As Integer
Dim lstrFiles(liNumSelect - 1) As String
Dim lstrFilesRemove() As String
Dim lstrFileRemove As String
Dim liIndexRemove As Integer

i = 0

For Each liIndex In lIndexes
lstrFiles(i) = ListViewImages.Items(liIndex).Text
i = i + 1

For i = 0 To lstrFiles.Length - 1
For j = 0 To ListViewImages.Items.Count
If lstrFiles(i) = ListViewImages.Items(j).Text Then
lstrFile = ListViewImages.Items(j).Text

IO.File.Delete(gstrPathImages & "\" & lstrFile)
IO.File.Delete(gstrPathImages & "\" & Microsoft.VisualBasic.Left(lstrFile, Len(lstrFile) - 4) & ".raw")


liIndexRemove = 0
lstrFilesRemove = IO.Directory.GetFiles(gstrPathImages, "*.BMP")
Dim lImage As System.Drawing.Image
For Each lstrFileRemove In lstrFilesRemove

lImage = lImage.FromFile(lstrFileRemove)
liIndexRemove = liIndexRemove + 1

lImage = Nothing

Exit For
End If
end sub
Anybody know that is the problem??



Nov 20 '05 #1
0 1538

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Silvia | last post: by
3 posts views Thread by Silvia | last post: by
4 posts views Thread by David | last post: by
2 posts views Thread by James | last post: by
8 posts views Thread by Nak | last post: by
3 posts views Thread by Lloyd Sheen | last post: by
3 posts views Thread by grzegorz.gazda | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.