Click here to Skip to main content
Rate this: bad
good
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 13:33pm

1 solution

Rate this: bad
good
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
2. Use the CB_FINDSTRING/CB_FINDSTRINGEXACT + CB_SETCUSEL pair.
 
    SendMessage(comboHwnd, CB_SELECTSTRING, 0, (LPARAM)buffer);
 
or
 
    index = SendMessage(comboHwnd, CB_FINDSTRING, -1, (LPARAM)buffer);
    if (index != CB_ERR)
        SendMessage(comboHwnd, CB_SETCURSEL, index, 0);
  Permalink  
Comments
Sandeep Mewara at 15-Jun-12 1:24am
   
My 5!
Ernst G. Gruber at 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
0 OriginalGriff 205
1 Sergey Alexandrovich Kryukov 185
2 jlopez788 144
3 Rob Philpott 100
4 Prakriti Goyal 97
0 OriginalGriff 6,837
1 Sergey Alexandrovich Kryukov 5,559
2 Maciej Los 3,479
3 Peter Leow 3,323
4 DamithSL 2,505


Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 14 Jun 2012
Copyright © CodeProject, 1999-2014
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