Changing Item Text In Combobox

Sep 1, 2011 at 8:55pm
I'm using the Win32 API to write an application where the user can create a list of items (combobox), and when he clicks on an item in the combobox, it allows them to change it's settings (by referencing the equivalent index in a separate array of objects). I would like to know how to change the text of the item in the combobox that the user has currently selected based on what they typed into an edit control.

I already know how to get the index of the selected item and get the text the user typed in to the edit control, I just need to know how to set the text of the selected item in the combobox.
Last edited on Sep 1, 2011 at 8:56pm
Sep 1, 2011 at 9:02pm
I believe the CB_SETITEMDATA message is what you're after

http://msdn.microsoft.com/en-us/library/bb775909(v=vs.85).aspx
Sep 1, 2011 at 9:46pm
I was looking at that and figured it's the command I wanted. How do I use it though? I tried

 
SendMessage(GetDlgItem(hWndDlg, CB_CHAPTERS), CB_SETITEMDATA, animationIndex, (LPARAM)dName);


but no luck. the "dName" variable is a LPSTR that contains what the user types in. I did debug the program, and it does contain a value when I execute the command above. I also checked to see if the "animationIndex" variable points to a valid index in the combobox, which it does.
Sep 2, 2011 at 3:44am
Whoops, sorry, it's actually CB_INSERTSTRING that you want :) (although I don't agree with the nomenclature)

http://msdn.microsoft.com/en-us/library/bb775875(v=VS.85).aspx
Last edited on Sep 2, 2011 at 3:45am
Sep 2, 2011 at 11:02am
<snip>...totally misleading and spurious response...</snip>

(mis-misread earlier responses...)
Last edited on Sep 2, 2011 at 11:19am
Topic archived. No new replies allowed.