Results 1 to 6 of 6

Thread: [RESOLVED] How to check if an Image is in an Imagelist?

  1. #1

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Resolved [RESOLVED] How to check if an Image is in an Imagelist?

    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?
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: How to check if an Image is in an Imagelist?

    Quote Originally Posted by [LGS]Static
    Is there an easier way than looping through checking each key?
    Not that I'm aware of.

  3. #3

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: How to check if an Image is in an Imagelist?

    ok.. I'll leave it open for a bit in case someone knows.. but for now thats what I'll use

    Thanks Hack!
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  4. #4
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: How to check if an Image is in an Imagelist?

    One option, although I don't think its any easier than a loop. How hard is it to code a loop?

    VB Code:
    1. Public Function ImageExists(ImageListCtl as ImageList, ByVal ItemKey As String) As Boolean
    2.     On Error Resume Next
    3.     Dim objItem As ListImage
    4.    
    5.     Set objItem = ImageListCtl.ListImages(ItemKey)
    6.     ImageExists = Not objItem Is Nothing
    7.    
    8. End Function

  5. #5

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: How to check if an Image is in an Imagelist?

    VB Code:
    1. Dim iFound As Boolean
    2.                 iFound = False
    3.                 For i = 1 To IL_Code.ListImages.Count
    4.                     If IL_Code.ListImages(i).Key = strKey Then
    5.                         iFound = True
    6.                         Exit For
    7.                     End If
    8.                 Next
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  6. #6

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: How to check if an Image is in an Imagelist?

    I like yours better.. since I have to test in multiple places I swiped you function and replaced mine
    Thanks!
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width