This is a custom WinForms style "combobox" which allows for entry of data by either typing in a value or selecting a value from a dropdown list. This is a very quick-and-dirty implementation done as a proof of concept for a client. Feel free to take some hints from this and build something better as this code is very specific.

Among the features you should note:

  1. Auto-complete. As you type, the script runs through a binary search through the "options" (actually list elements) to find the best match value. This search can be improved by adding support for:
    1. Selecting the lowest value that matches the criteria. For example, when you type "p", it matches "pineapple" and not "papaya" since "pineapple" is the first match using a pure binary search algorithm.
    2. Using a property to hold the last known match. There's no reason to do a binary search for "ma" and then "man" from scratch. The search should keep tabs on where the last match was found when a user is typing.
    3. Note that for the binary search to work, the list item values must be in sorted ascending order.
  2. Direction pad nagivation. You can navigate the dropdown list by pressing up or down on your directional pad. Hit enter to select a value.
  3. Value highlighting. Highlighting on both mouseover and directional pad navigation to show current selection.
  4. Auto-hide. The dropdown list fades out after a few seconds of inactivity.

The following is the list of all values: Apple, Apricot, Avocado, Banana, Blueberry, Cactus Pear, Cantaloupe, Cherry, Dragon Fruit, Fig, Grape, Guava, Honeydew, Kiwi, Lemon, Mango, Nectarine, Orange, Papaya, Passion Fruit, Peach, Pear, Persimmon, Pineapple, Plum, Pomegranate, Raspberry, Star Fruit, Strawberry, Tangerine, Watermelon