Solved

API Search of itemdata on combobox and listbox

Posted on 2003-11-03
9
786 Views
Last Modified: 2013-12-25
I've used an API call to SendMessage using the LB_FINDSTRINGEXACT or CB_FINDSTRING to search a listbox or combo box.  It there a corresponding ability to search the itemdata field instead of the list field?  Right now I'm just using a for-next loop to search it and was wondering it that was the best approach.
0
Comment
Question by:rkbcpi
9 Comments
 
LVL 48

Expert Comment

by:Mikal613
Comment Utility
Use LB_GETITEMDATA
0
 
LVL 48

Expert Comment

by:Mikal613
Comment Utility
Its the fastest


Another would be loop through all the Entries and select the ListIndex OF the Itemdata your looking for

0
 
LVL 48

Expert Comment

by:Mikal613
Comment Utility
Private Const LB_GETITEMDATA = &H199
0
 

Author Comment

by:rkbcpi
Comment Utility
I looked at LB_GETITEMDATA earlier and it looks like it returns the itemdata if you supply the index.  What I wanted to know was if there was an API that would behave like the SendMessage using the LB_FINDSTRINGEXACT, but which searched the itemdata entries of a list/combo box and returned the index of the matching entry.  I am currently using a for..next look, but was looking for something that might be a little more efficient.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 48

Accepted Solution

by:
Mikal613 earned 125 total points
Comment Utility
Your Gonna have to do it the olod fashioned way

Public Function SearchByItemData (ItemData as long) as Integer
  Dim I as Long
  For i = 0 to Combo.ListCount

     If Combo.item(i).Itemdata = Itemdata
          SearchByItemData  = i
     end if

  next
End Function
0
 
LVL 5

Expert Comment

by:fantasy1001
Comment Utility
This is microsoft example of search using sendmessage, it will return the index of corresponding itemdata
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dnarvbtips/html/msdn_msdn115.asp

~ fantasy ~
0
 
LVL 48

Expert Comment

by:AlexFM
Comment Utility
Such API doesn't exist since Windows has no idea what is item data - this is just DWORD, which may be, for example, pointer to some structure. You may create collection with item data as key and item index as data. However, simple loop is the best way to do this.
0
 
LVL 5

Expert Comment

by:rajaamirapu
Comment Utility
0
 

Author Comment

by:rkbcpi
Comment Utility
Thanks, that's what I'm doing now.  Just checking to see if there was a better way to do it.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now