开发者

Free WinForm combo with support for dynamic searches

开发者 https://www.devze.com 2023-02-19 00:38 出处:网络
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

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;
0

精彩评论

暂无评论...
验证码 换一张
取 消