How do I check if an image has been added to an imagelist?
I assign a Key to each one.. and need to check by key.
Is there an easier way than looping through checking each key?
Printable View
How do I check if an image has been added to an imagelist?
I assign a Key to each one.. and need to check by key.
Is there an easier way than looping through checking each key?
Not that I'm aware of.Quote:
Originally Posted by [LGS]Static
ok.. I'll leave it open for a bit in case someone knows.. but for now thats what I'll use
Thanks Hack!
One option, although I don't think its any easier than a loop. How hard is it to code a loop?
VB Code:
Public Function ImageExists(ImageListCtl as ImageList, ByVal ItemKey As String) As Boolean On Error Resume Next Dim objItem As ListImage Set objItem = ImageListCtl.ListImages(ItemKey) ImageExists = Not objItem Is Nothing End Function
VB Code:
Dim iFound As Boolean iFound = False For i = 1 To IL_Code.ListImages.Count If IL_Code.ListImages(i).Key = strKey Then iFound = True Exit For End If Next
I like yours better.. since I have to test in multiple places I swiped you function and replaced mine ;)
Thanks!