I have a textbox with autocomplete mode. When I enter first few characters, the suggestion list items exceeds more than 15. I want the suggestion items to show maximum of 10 items.
I don't find property to do it.
AutoCompleteStringCollection ac = new AutoCompleteStringCollection();
ac.AddRange(this.Source());
if (textBox1 != null)
{
textBox1.AutoCompleteMode = AutoCompleteMode.Suggest;
textBox1.AutoCompleteCustomSource = ac;
textBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
}
You can't use LINQ on the AutoCompleteStringCollection class. I suggest you handle the filtering yourself in the TextChanged event of the TextBox. I have written some test code below. After entering some text, we will filter and take the top 10 matches from your Source() data set. Then we can set a new AutoCompleteCustomSource for your TextBox. I tested it and this works: