i have a list box with over 300 items, and text box to filter these items on a user input, and i am using the following code:
private void textBox1_TextChanged(object sender, EventArgs e)
listBox1.DataSource = null;
string Searchtxt = textBox1.Text;
List<string> keys = kvpList
.Where(kvp => kvp.Value.ToString().StartsWith(Searchtxt))
.Select(kvp => kvp.Value)
listBox1.DataSource = new BindingSource(keys, null);
my problem is that this code is taking long time (3-4 sec and sometimes more) to get the filtered list.
i wanna know what is the problem with this code, is it the keyvalue pair i am using or its a performance issue from the device, or maybe it is the code itself.
can any one suggest how to do this filtration with a different way that doesn't have this performance issue?