[英]Flickring issue in Textbox when using auto complete in c#
我正在使用自定义自动来源到文本框。 但是问题是,当我输入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;
我将强烈建议您使用将其AutoCompleteMode设置为Suggest
的组合框,并将自动完成列表附加到它(作为其AutoCompleteSource )。 它的性能将比您的textchanged事件侦听器更好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.