ListBox items as AutoCompleteCustomSource for a textbox

后端 未结 3 773
谎友^
谎友^ 2021-01-25 16:48

I have populated some items into a listbox using the datasource property. Now I need to set the AutoCompleteCustomSource for a textBox from the items listed in the listbox. Prec

3条回答
  •  忘了有多久
    2021-01-25 17:51

    The AutoCompleteStringCollection takes only string[], so it should be like this:

    var cc = new AutoCompleteStringCollection();
    cc.AddRange(listBox1.Items.Cast().ToArray());
    

提交回复
热议问题