Hey guys,
I'm writing a filter that will pick out items. I have a list of Objects. The objects contain a number, name and some other irrelevant items. At the moment, the list contains 200 items. When typing in a textbox, i'm looking if the string matches a part of the number/name of the objects in the list. If so, add them to the listbox. Here's the code for my textbox textchanged event :
private void txtTelnumber_TextChanged(object sender, TextChangedEventArgs e)
{
lstOverview.Items.Clear();
string data = "";
foreach (ucTelListItem telList in _allUsers)
{
data = telList.User.H323 + telList.user.E164;
if (data.Contains(txtTelnumber.Text))
lstOverview.Items.Add(telList);
}
}
I sometimes see a little delay when entering a character, especially when i go from 4 records to 200 records (so when i had a filter and 4 records matched, and i backspace and the whole list appears again). My list is a list of usercontrols, cause i found it takes less time to load the usercontrols from a list, then to have to initialize a new usercontrol each time.
Can i do something about the code, or is it just adding the usercontrol the listbox that causes the small delay (small delay = <1 sec)?
Thanks in advance.
Edit I've edited post, it's wpf. And putting items in a list and setting the itemssource isn't solving the problem.