Disabling the Combobox's Autocomplete feature.

When a combobox's edit field has a value, and the UpdateData(FALSE) is called, the combobox automatically
selects a value from the list part of the combo, matching the value in the edit field. Is there any way to
turn off this feature ?

Removing the Combobox control from DDX would prevent the autocomplete feature, but it would also mean that I'd had to access the control manually every time I want to use it.

Isn't there any other way of disabling this autocompletion feature ?

The problem is that a user types in data in the Combobox's edit field, TAB's on to the next control, and
in that control's Event map, the UpdateData(FALSE) is called - making all of my Comboboxes autocomplete.

Morten from ElitenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vinayak KumbarSr Program ManagerCommented:
Hi,

How u want the combo to behave for such entries?. Say combo contains
One
Three
Two

Then if u type 'O' and proceed, it will select One. Ok?. Instead what do u want?. U want 'O' should be inserted into the combo, so that now list becomes
O
One
Three
Two.

Or U want to retain the previous selection?.

If U dont want to enter the user edited data into the list, then don't allow the user to enter the data by changing the property of combo to DropDownList. If U want ot retain prev selection, then maintain one variable for that and use it to select again.

Try it out.
VinExpert

0
Morten from ElitenAuthor Commented:
I want the combo to stay the way it is, when UpdateData is called, instead of selecting one of the entries in the list box.

Using the example you gave (Having "One", "Three", "Two" as List-entries), if I type "O" in the ComboBox's Editbox, and I call UpdateData, I want "O" to stay an "O" instead of being "One". Can this be done, in any way, without adding "O" to the ComboBox's list ?
0
SteveGTRCommented:
Make the style for the Combobox "Dropdown" (CBS_DROPDOWN).
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Morten from ElitenAuthor Commented:
The ComboBox's style IS dropdown. If if wasn't I wouldn't be able to enter my own piece of text in it.
0
SteveGTRCommented:
True... Can you open your resource file (projectname.rc) and post the resource code for your combo box? Here's an example:

    COMBOBOX        IDC_OWNERGRNTNUM,164,853,54,30,CBS_DROPDOWN | CBS_SORT |
                    WS_VSCROLL | WS_TABSTOP,0,HIDC_OWNERGRNTNUM
0
Morten from ElitenAuthor Commented:
This is it:
COMBOBOX IDC_COMBO, 45, 85, 100, 55, CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP
0
SteveGTRCommented:
The combo should not be doing this. Nothing in the resource script you supplied above points to that. I went back to your original message and have some questions:

"Removing the Combobox control from DDX would prevent the autocomplete feature, but it would also mean that I'd had to access the control manually every time I want to use it."

What are the DDX statement(s) in your DoDataExchange() function? What are the parameters to these statements. For example:

DDX_CBString(pDX, IDC_OWNERGRNTNUM, m_OwnerGrntNum);

CString m_OwnerGrntNum ;

"The problem is that a user types in data in the Combobox's edit field, TAB's on to the next control, and
in that control's Event map, the UpdateData(FALSE) is called - making all of my Comboboxes autocomplete."

Pressing TAB, i.e. losing focus, does not by default call UpdateData(FALSE). UpdateData(FALSE) calls your DoDataExchange() function. What messages are you handling for this control and could some of your code there be doing this? Try remooving it and see if it behaves the same.

It appears that something is going on here that you aren't telling us. I hope these questions will enlighten both you and us.

Thanks,
Steve
0
Morten from ElitenAuthor Commented:
It appears that you have answered my question, by yourself asking the right questions.

I have these DDX's:
DDX_Control(pDX, IDC_COMBO, m_comboThingy);
DDX_CBString(pDX, IDC_COMBO, m_sComboThingy);

If I remove the DDX_CBString(), the problem that I describe doesn't occur. I didn't know of any problems with mapping two variables to the same control, should there be ?


0
SteveGTRCommented:
So... m_sComoboThingy is a CString? m_comboThingy is CComboBox?
0
Morten from ElitenAuthor Commented:
That's right, and they're both mapped to the same control.
0
SteveGTRCommented:
The problem is DDX_CBString(). The documentation for this says:

"When DDX_CBString is called, value is set to the current combo box selection. If no item is selected, value is set to a string of zero length."

I looked at that twice before I realized what it was saying. The value is set to the "current combo box selection". If you want to capture the value of the combo box I'd suggest using DDX_Text(). This will do the trick!

Steve
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.