2

The WinForms combobox does not support dynamic population of the autocomplete items. Is anyone aware of a free control or control suite which contains a drop down list that enables me to populate autocomplete items on KeyPress and display that list?

Something along the lines of the jQuery UI combo would be ideal, but for WinForms.

Sam
  • 4,219
  • 7
  • 52
  • 80
  • 1
    Not aware of a free one that does that, but you could write your own ComboBox control to handle those auto complete commands, or use a paid for library like DevComponents (which i use extensively), to take care of that. –  Jun 17 '11 at 13:36
  • See this question: http://stackoverflow.com/questions/796195/c-autocomplete – Ezekiel Rage Aug 31 '11 at 19:50

1 Answers1

0

Use below code to implement auto complete functionality:

            cmb.DisplayMember = "Name"; //column name for display
            cmb.ValueMember = "ID";     //table id column name

            DataTable userDT = datasource; //supply datasource
            AutoCompleteStringCollection AutoComp = new AutoCompleteStringCollection();

            foreach (DataRow dr in userDT.Rows)
            {
                AutoComp.Add(dr["Name"].ToString());
            }

            cmb.DataSource = userDT;
            cmb.AutoCompleteMode = AutoCompleteMode.Suggest;
            cmb.AutoCompleteSource = AutoCompleteSource.CustomSource;
            cmb.AutoCompleteCustomSource = AutoComp;
Priyank
  • 1,219
  • 11
  • 30