Auto Complete In Textbox C#

  • Bring Data In DataTable.
  • Create the Function¬† and Call at Load Event.

public void AutofillTextbox()


AutoCompleteStringCollection Auto = new AutoCompleteStringCollection();

for (int i = 0; i < DTItem.Rows.Count; i++) //DTItem is a DataTable Name.

Auto.Add(DTItem.Rows[i][“CategoryName”].ToString()); // CategoryName is the Name of Columm in DataTable that has to be AutoComplete in TextBox.

TxtSearch.AutoCompleteMode = AutoCompleteMode.Suggest; //TxtSearch is the Textbox in Which AutoComplete is Set.
TxtSearch.AutoCompleteSource = AutoCompleteSource.CustomSource;
TxtSearch.AutoCompleteCustomSource = Auto;


Write a Comment

Your email address will not be published. Required fields are marked *