C# Tutorial

Autocomplete Text in ComboBox Using C#
Previous Home Next

We can also create AutoCompleteStringCollection programmatically. The following code creates an AutoCompleteStringCollection, adds strings to the collection, and sets it to the AutoCompleteCustomSource of the ComboBox

Code For AutoComplete Text in ComboBox Using C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class combobox : Form
{
public combobox()
{
InitializeComponent();
}
private void combobox_Load(object sender, EventArgs e)
{
AutoCompleteStringCollection data = new 
	AutoCompleteStringCollection();
 data.Add("Mohit");
 data.Add("Mukandlal");
 data.Add("Mukesh");
 data.Add("Manju");
 data.Add("Alok");
 data.Add("Amit");
 data.Add("Ashish");
comboBox1.AutoCompleteMode = AutoCompleteMode.Suggest;
comboBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
comboBox1.AutoCompleteCustomSource = data;
}
}
}

 

output

Previous Home Next

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Name:
eMail:
Comment / Feedback: