Free WinForm combo with support for dynamic searches
The WinForms combobox does not support dynamic population of the autocomplete items. Is anyone aware of a free control or control suite whi开发者_如何学编程ch 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.
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;
精彩评论