ListBox中的项目,如AutoCompleteCustomSource一个TextBox项目、ListBox、TextBox、AutoCompleteCustomSource

由网友(你输,我陪你东山再起)分享简介:我已经填充了一些项目到使用DataSource属性列表框。现在,我需要设置AutoCompleteCustomSource从列表框中列出的项目一个文本框。 precisely,数据源的列表框和AutoCompleteCustomSource对TextBox相同。我怎样才能设置AutoCompleteCustomSour...

我已经填充了一些项目到使用DataSource属性列表框。现在,我需要设置AutoCompleteCustomSource从列表框中列出的项目一个文本框。 precisely,数据源的列表框和AutoCompleteCustomSource对TextBox相同。我怎样才能设置AutoCompleteCustomSource不使用for循环? NET 2.0只。没有对LINQ的支持

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. Precisely, the DataSource for the ListBox and the AutoCompleteCustomSource for the textBox are same. How can I set the AutoCompleteCustomSource without using the for-loops? .Net 2.0 only. No support for LINQ

推荐答案

AutoCompleteStringCollection 只需的String [] ,所以它应该是这样的:

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

var cc = new AutoCompleteStringCollection();
cc.AddRange(listBox1.Items.Cast<string>().ToArray());
阅读全文

相关推荐

最新文章