Use an Auto-Complete Combo Box

Problem

You want to create a combo box that automatically completes what the user is typing based on the item list.

Solution

You can implement a basic auto-complete combo box by handling the KeyPress event.

Discussion

Many professional applications include some type of auto-complete control. This control might fill in values based on a list of recent selections (as Microsoft Excel does when entering cell values) or might display a drop-down list of near matches (as Internet Explorer does when typing a URL). You can create a basic auto-complete combo box by handling the KeyPress and TextChanged events, searching for matching items in the appropriate list, and then filling in the appropriate item. The important step is ...

Get Microsoft® Visual Basic® .NET Programmer's Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.