I am trying to filter items in a ListView
by using a TextBox
.
I've managed to make something, but it can only delete items from my listview, not bring them back. Here is a little example of my code:
private void textBox1_TextChanged(object sender, EventArgs e)
{
string value = textBox1.Text.ToLower();
for (int i = listView1.Items.Count - 1; -1 < i; i--)
{
if
(listView1.Items[i].Text.ToLower().StartsWith(value) == false)
{
listView1.Items[i].Remove();
}
}
}
Does anybody has an idea on how to retrieve the deleted items? I can't seem to figure it out >:...
Items
is an ordinary collection; once you remove the items, they're gone. You would have to store the removed items somewhere (perhaps in another collection) if you wanted to restore them later. – Inconformity