- Blanking ComboBox Display
- Posted by Larry Lindstrom on April 14th, 2004
Hi Experts:
I want to display the value of a selected
record's field in a combo box.
If the value hasn't been defined for that
record, I want the collapsed combo box to
display a blank for the selected text.
When I bring the enclosing dialog box up,
the combo box shows a blank. And the display
changes as each record with a legal value is
selected. But I'm not seeing a method to
force text, in this case blank, that isn't
one of the entries in the dropdown list.
I can live with creating a combo box list
element with a blank entry, but I'd rather not
have a blank entry as a choice a user might
select.
Thanks
Larry
- Posted by Larry Lindstrom on April 14th, 2004
Larry Lindstrom wrote:
I've tried passing an index of "-1" to the
combo box, and it's now displaying a blank, as
I want.
Is this a safe way to de-select a combobox's
selection, and display a blank, for all Windows
versions? I'm developing on Win2K, but I need
to support Win98 onward.
Thanks
Larry
- Posted by Tim Robinson on April 14th, 2004
Larry Lindstrom wrote:
That's fine, as long as your code copes with LB_GETCURSEL returning -1.
--
Tim Robinson (MVP, Windows SDK)
http://mobius.sourceforge.net/
- Posted by Larry Lindstrom on April 14th, 2004
Tim Robinson wrote:
Thanks Tim:
I hadn't thought to check the index, I will now.
Is this the recommended method to reset a combobox?
Minor typo - I think the message is "CB_GETCURSEL".
Because a combobox is a type of listbox, they might
be the same message.
Thanks
Larry
- Posted by Tim Robinson on April 14th, 2004
Larry Lindstrom wrote:
[...]
I don't know of any other method...
You're right
. I was originally in MFC mode and wrote GetCurSel. I thought
I ought to write the Windows message name instead, and got the wrong one.
Annoyingly, some LB_xxx messages have the same values as some CB_xxx
messages, so this can work by accident.
--
Tim Robinson (MVP, Windows SDK)
http://mobius.sourceforge.net/