0
votes

The combo box which I created is not auto completing words stored in a list after typing in the first letter and quickly pressing "Tab". However if you type in slowly and then press "Tab". It's auto completes. I have figured out that the issue is with the key_down event. When you keep a key pressed then press "Tab" it doesn't auto completes, where as if you release the key and then press "Tab" it auto completes.

If I start typing in the second character and then "Tab" out it auto completes.

Key_up event:

private void cboReasonCd_KeyUp(Object eventSender, KeyEventArgs eventArgs)
    {
        int KeyCode = (int)eventArgs.KeyCode;
        int Shift = (int)eventArgs.KeyData / 0x10000;
        CancelFillCbo.ComboReasonCD_KeyUp(KeyCode, Shift);

    }

Here CancelFillCbo is the form name and ComboReasonCD method is used to populate the list.

Key_Down event:

private void cboReasonCd_KeyDown(object sender, KeyEventArgs e)
    {
        mlCurrentPosition = cboReasonCd.SelectionStart;
    }

cboReasonCd is the name of combo box.

1

1 Answers

0
votes

Have you tried built-in autocomplete? You don't need pressing tab. However if you want to write your own autocomplete, use textbox and TextChanged event to display matching words, or keydown event detecting if tab has been pressed to show them.