473,503 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Delete images from listview

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
Jul 19 '05 #1
0 1902

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
337
by: Anushya | last post by:
Hi all i tried to add items to listview using addrange and it is very slow.. then tried using virtual listview which allows to add only text(it is quite fast).. Now i just want to mix up this...
3
1822
by: Silvia | last post by:
Hello I have a listview with images, and when I select one image I can delete the image, bu I produce an error, say "the process cannot access the file D:\imagesDicomitzador\142617379\image1.bmp...
2
8607
by: Kanaiya | last post by:
hello how to put images in either listbox or listview.bye. -- With regards, Gangani Kanaiya.
4
4523
by: David | last post by:
hello to everybody... in of directories on my pc i have a list of su-directories, and in each directory theres an image "picture.ico"... so then my program is starting to run, i add a new...
5
11633
by: luis | last post by:
Hi I would like to use a listview to show the tumbnails of images, the problem is the the images are shown too small, Is there any way to change the image size If it is not possible, is there...
0
1805
by: Silvia | last post by:
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...
6
6834
by: Samuel R. Neff | last post by:
I'm trying to put icons in the header of my ListView. All the .net posts I found refer to an example on thecodeproject which is no longer there (part of commercial package now). I converted the...
1
4626
by: Steve | last post by:
OK, I am stumped. I cannot for the life of me get images to show in ListView items while the view is set to Details. I create an ImageList, set the SmallImageList to point to the ImageList, then...
1
1599
by: Diego F. | last post by:
Hi. I'm having a problem with listview controls. I'm using a control that adds drag and drop functionality to a listview (I get the control from codeproject). Now I'm having problems when...
0
7204
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7282
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7464
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5018
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4680
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3171
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1516
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
741
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
391
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.