Auto filter Combo box

I need to implement a VC++ combo box that allows the user to type in the edit portion of the box, and automatically searches to the first entry in the list with the character typed. I want to do this for however many characters are typed. The only examples I can find are for DHTLM pages. I need to use this for a combo box on a dialog.
Any ideas?

Comments

  • : I need to implement a VC++ combo box that allows the user to type in the edit portion of the box, and automatically searches to the first entry in the list with the character typed. I want to do this for however many characters are typed. The only examples I can find are for DHTLM pages. I need to use this for a combo box on a dialog.
    : Any ideas?
    :
    [blue]Every time you type something in combo box editor you will receive 'CBN_EDITCHANGE'. Use 'CComboBox::FindString()' to see if the entry is in the list.[/blue]
  • : : I need to implement a VC++ combo box that allows the user to type in the edit portion of the box, and automatically searches to the first entry in the list with the character typed. I want to do this for however many characters are typed. The only examples I can find are for DHTLM pages. I need to use this for a combo box on a dialog.
    : : Any ideas?
    : :
    : [blue]Every time you type something in combo box editor you will receive 'CBN_EDITCHANGE'. Use 'CComboBox::FindString()' to see if the entry is in the list.[/blue]
    : :
    : [red]I managed to get that far. I believe I have it working except that it doesn't allow character deletion using the delete or backspace keys. Here's the code in my CBN_EDITCHANGE event...[/red]
    [size=1][code]
    void CommanderWindowDlg::onTypedCommand()
    {
    CString stringToFind = "";
    int selIndex = 0;
    static int prevIndex = 0;
    int numCharsTyped = 0;
    int selectRemainder = 0;

    //Get text from the edit portion of the combo box
    cmdSelect.GetWindowText(stringToFind);
    numCharsTyped = stringToFind.GetLength();
    //Copy entry to editbox if found
    selIndex = cmdSelect.SelectString(-1, stringToFind);

    if(selIndex != CB_ERR)
    {
    //Select only the characters AFTER what was typed by the user
    cmdSelect.SetEditSel(numCharsTyped, -1);
    prevIndex = selIndex;
    }
    else
    {
    //Not found so set selection back to previous
    cmdSelect.SetCurSel(prevIndex);
    //Select only the characters AFTER what was typed by the user
    cmdSelect.SetEditSel(numCharsTyped - 1, -1);
    }
    }[/code][/size]

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories