I have a question regarding the TextBox AutoCompleteMode property. I have set the TextBox AutoCompleteMode to "Suggest" and have set AutoCompleteSource to CustomerSource. I have an AutoCompleteCustomSource collection:
"A"
"A" "AA" "AAA"When I type "A" into the TextBox, it suggests only one "A开发者_运维知识库" item, and not any of the other possibilities, including the other "A" item. Why is this? How can I get it to display all duplicates and other related items?
Thanks in advance.
I don't think it's possible without doing all the work yourself, unfortunately (e.g. by creating your own custom control that is a TextBox with duplicates-friendly auto-complete).
However, I'm not quite sure why you want duplicates to appear? Since the 2 strings are equal, what difference would there be to auto-complete with one or the other?
I've configured the textbox to use an autocomplete custom source and it works fine. Of course, it filters duplicated, because they are strings and it has no sense to show duplicated string entries. But the rest of the entries are correctly shown:
Here is the code I used:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
TextBox textBox1 = new TextBox();
textBox1.AutoCompleteCustomSource.AddRange(new string[] {
"A",
"A",
"AA",
"AAA"});
textBox1.AutoCompleteMode = AutoCompleteMode.Suggest;
textBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
this.Controls.Add(textBox1);
}
精彩评论