S
Silvia
Hi,
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
Next
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
ListViewImages.Items(j).Remove()
IO.File.Delete(gstrPathImages & "\" & lstrFile)
IO.File.Delete(gstrPathImages & "\" & Microsoft.VisualBasic.Left(lstrFile, Len(lstrFile) - 4) & ".raw")
ImageList.Images.Clear()
liIndexRemove = 0
lstrFilesRemove = IO.Directory.GetFiles(gstrPathImages, "*.BMP")
Dim lImage As System.Drawing.Image
For Each lstrFileRemove In lstrFilesRemove
lImage = lImage.FromFile(lstrFileRemove)
ImageList.Images.Add(lImage)
liIndexRemove = liIndexRemove + 1
Next
lImage.Dispose()
lImage = Nothing
Exit For
End If
Next
Next
end sub
Anybody know that is the problem??
Thanks
Silvia
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
Next
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
ListViewImages.Items(j).Remove()
IO.File.Delete(gstrPathImages & "\" & lstrFile)
IO.File.Delete(gstrPathImages & "\" & Microsoft.VisualBasic.Left(lstrFile, Len(lstrFile) - 4) & ".raw")
ImageList.Images.Clear()
liIndexRemove = 0
lstrFilesRemove = IO.Directory.GetFiles(gstrPathImages, "*.BMP")
Dim lImage As System.Drawing.Image
For Each lstrFileRemove In lstrFilesRemove
lImage = lImage.FromFile(lstrFileRemove)
ImageList.Images.Add(lImage)
liIndexRemove = liIndexRemove + 1
Next
lImage.Dispose()
lImage = Nothing
Exit For
End If
Next
Next
end sub
Anybody know that is the problem??
Thanks
Silvia