Click here to Skip to main content
11,929,283 members (50,109 online)
Rate this:
Please Sign up or sign in to vote.
See more: C++ Windows
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 14: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

Advertise | Privacy | Mobile
Web02 | 2.8.151126.1 | Last Updated 14 Jun 2012
Copyright © CodeProject, 1999-2015
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