Solved

API Search of itemdata on combobox and listbox

Posted on 2003-11-03
9
791 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
ID: 9673353
Use LB_GETITEMDATA
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 9673365
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
ID: 9673409
Private Const LB_GETITEMDATA = &H199
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

Author Comment

by:rkbcpi
ID: 9673685
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
 
LVL 48

Accepted Solution

by:
Mikal613 earned 125 total points
ID: 9675758
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
ID: 9676145
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
ID: 9676679
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
ID: 9676980
0
 

Author Comment

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

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

776 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