[英]Flickring issue in Textbox when using auto complete in c#
i am using custom auto source to the text box. 我正在使用自定义自动来源到文本框。 But the problem is, when i am entering key , if the suggestion list is high then the textbox flickers before showing suggestion. 但是问题是,当我输入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);
}
}
}
}
I have declared following code on form load event 我在表单加载事件中声明了以下代码
suggestion = new AutoCompleteStringCollection();
txtSearch.AutoCompleteCustomSource = suggestion;
txtSearch.AutoCompleteMode = AutoCompleteMode.Suggest;
txtSearch.AutoCompleteSource = AutoCompleteSource.CustomSource;
I will seriously encourage you to use a Combobox with its AutoCompleteMode set to Suggest
and attach the autocomplete list to it (as its AutoCompleteSource ). 我将强烈建议您使用将其AutoCompleteMode设置为Suggest
的组合框,并将自动完成列表附加到它(作为其AutoCompleteSource )。 It'll performt way better than your textchanged event listener. 它的性能将比您的textchanged事件侦听器更好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.