Click here to Skip to main content
12,953,700 members (44,308 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Gentle people,
Could somebody please give me a push in the right direction?
There is an array of hundreds of strings to be filled from a list of thousands. Hence I thought it'd be a good idea to have a single combobox with the thousands of strings in the list and move it at random onto the elements of the array currently displayed on the screen and fill the element selected from the combobox list.

Well, all of this works as designed except for one thing - no matter what I do (and I have tried a lot), the combobox always shows the last item selected from the combobox list in the edit part, but when I select the next element I want to see the current contents of this element, not that of the last one.

Naively I assumed a simple SETTEXT to the edit part of the combobox would do the job. Unfortunately it does not.

Any ideas?
Posted 14-Jun-12 13:33pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

As far as I know, there's 2 ways to go about this (I think they're functionally identical):

1. Use the CB_SELECTSTRING message

SendMessage(comboHwnd, CB_SELECTSTRING, 0, (LPARAM)buffer);


index = SendMessage(comboHwnd, CB_FINDSTRING, -1, (LPARAM)buffer);
if (index != CB_ERR)
    SendMessage(comboHwnd, CB_SETCURSEL, index, 0);
Sandeep Mewara 15-Jun-12 1:24am
My 5!
Ernst G. Gruber 15-Jun-12 7:08am
Thanks a lot for the answer! The FINDSTRING method you mentioned was my plan B, but seemed to be not very elegant, for all the information necessary is already available. Additionally one needs an empty entry in the list to take care of empty elements in the array ...
Well, you can't win them all! Thank you again for your help!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,429
CHill60 3,490
Maciej Los 3,103
ppolymorphe 2,020
Jochen Arndt 1,975

Advertise | Privacy | Mobile
Web01 | 2.8.170525.1 | Last Updated 14 Jun 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100