---
title: "Auto Complete Combobox in C#"  
description: "This code is written in ComboBox KeyUp event as we have tocheck after every new character is typed.private void comboBox1_KeyUp(objectsender, KeyEvent"  
author: "Uttam Misra"  
published: 2011-01-08  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/93/auto-complete-combobox-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Auto Complete Combobox in C#

This [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) is written in [ComboBox](https://www.mindstick.com/articles/57/display-record-according-to-combobox-selection-in-csharp-dot-net) KeyUp [event](https://www.mindstick.com/articles/167719/marquee-hire-benefits-of-event-lighting-hire-london) as we have tocheck after every new [character](https://www.mindstick.com/articles/23551/an-investigate-distinctive-seafood-restaurant-for-your-image-stamp-character) is [typed](https://www.mindstick.com/interview/33645/what-is-the-difference-between-typed-and-untyped-dataset).

```
private void comboBox1_KeyUp(objectsender, KeyEventArgs e)        {            intindex;            stringactual;            stringfound;             // Donothing for certain keys, such as navigation keys.            if((e.KeyCode == Keys.Back) ||            (e.KeyCode == Keys.Left) ||            (e.KeyCode == Keys.Right) ||            (e.KeyCode == Keys.Up) ||            (e.KeyCode == Keys.Down) ||            (e.KeyCode == Keys.Delete) ||            (e.KeyCode == Keys.PageUp) ||            (e.KeyCode == Keys.PageDown) ||            (e.KeyCode == Keys.Home) ||            (e.KeyCode == Keys.End))            {                return;            }             // Storethe actual text that has been typed.            actual = this.comboBox1.Text;             // Findthe first match for the typed value.            index = this.comboBox1.FindString(actual);             // Getthe text of the first match.            if(index > -1)            {                found = this.comboBox1.Items[index].ToString();                 //Select this item from the list.                this.comboBox1.SelectedIndex= index;                 //Select the portion of the text that was automatically                //added so that additional typing replaces it.                this.comboBox1.SelectionStart= actual.Length;                this.comboBox1.SelectionLength= found.Length;            }        }
```

---

Original Source: https://www.mindstick.com/blog/93/auto-complete-combobox-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
