我正在对文本框使用自定义自动源。但问题是,当我输入 key 时,如果建议列表很高,那么文本框会在显示建议之前闪烁。
private void txtSearch_TextChanged(object sender, EventArgs e)
{
if (txtSearch.Text != "")
{
string templateSearchTxt = txtSearch.Text;
foreach (String template in templateName) // templateName contains list of string
{
if (template.ToUpper().StartsWith(templateSearchTxt.ToUpper()))
{
suggestion.Add(template);
}
}
}
}
我在表单加载事件中声明了以下代码
suggestion = new AutoCompleteStringCollection();
txtSearch.AutoCompleteCustomSource = suggestion;
txtSearch.AutoCompleteMode = AutoCompleteMode.Suggest;
txtSearch.AutoCompleteSource = AutoCompleteSource.CustomSource;