|
-
September 12th, 2008, 10:20 AM
#1
Programmatically change combobox
I need to update a combobox with a new value so it changes the reflected text in it. The cleanest way to do this is after the combobox has been initialised and with a message.
So I am trying to craft a postmessage to the hwnd that contains the combobox.
So if I want to send a message to it, changing the currently selected item to the nth item, what would the PostMessage look like?
I am guessing that it would involve ON_CBN_SELCHANGE, but I can't get it to work right.
Thanks, G.
-
September 12th, 2008, 10:39 AM
#2
Re: Programmatically change combobox
 Originally Posted by grahamr (work)
I need to update a combobox with a new value ...
I am guessing that it would involve ON_CBN_SELCHANGE, but I can't get it to work right.
No, you guessed wrong.
CBN_SELCHANGE is a notification message being sent when the user changes the current selection in the list box of a combo box.
To change selection programmatically using pülain Win32 APIs you need to SendMessage CB_SETCURSEL (or CB_SELECTSTRING).
If you are using MFC (which would be more easier to develop) - then have a look at the CComboBox::SetCurSel, CComboBox::SelectString methods.
Victor Nijegorodov
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|