?
Solved

Disabling the Combobox's Autocomplete feature.

Posted on 2000-01-09
11
Medium Priority
?
971 Views
Last Modified: 2013-11-20
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.

0
Comment
Question by:Morten from Eliten
  • 5
  • 5
11 Comments
 
LVL 8

Expert Comment

by:Vinayak Kumbar
ID: 2335896
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
 

Author Comment

by:Morten from Eliten
ID: 2337706
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
 
LVL 30

Expert Comment

by:SteveGTR
ID: 2338916
Make the style for the Combobox "Dropdown" (CBS_DROPDOWN).
0
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 

Author Comment

by:Morten from Eliten
ID: 2341020
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
 
LVL 30

Expert Comment

by:SteveGTR
ID: 2343429
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
 

Author Comment

by:Morten from Eliten
ID: 2344353
This is it:
COMBOBOX IDC_COMBO, 45, 85, 100, 55, CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP
0
 
LVL 30

Expert Comment

by:SteveGTR
ID: 2345709
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
 

Author Comment

by:Morten from Eliten
ID: 2348396
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
 
LVL 30

Expert Comment

by:SteveGTR
ID: 2349722
So... m_sComoboThingy is a CString? m_comboThingy is CComboBox?
0
 

Author Comment

by:Morten from Eliten
ID: 2352100
That's right, and they're both mapped to the same control.
0
 
LVL 30

Accepted Solution

by:
SteveGTR earned 300 total points
ID: 2353448
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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Watch the video to learn how one can deal with PST file corruption issue with an outstanding Kernel for Outlook PST Repair Tool easily. Using this tool, non-technical users can swiftly perform the repair process to restore their essential data witho…
Suggested Courses

600 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question