title: Search listview items using textbox
body: <p>I am working on a simple application (phonebook) in C# and in my project I have got a listview filled with contacts. I have been trying to implement the possibility to automatically (instantly) search through a listview using a textbox. I have managed to make it work, but not in the desired way. You will realise the actual problem if I give you an example. Let's say that I have got a contact named <strong>Bill Gates</strong> and when I try searching for it - it gets found and that part is OK. But, the problem is when I try to search for another contact. In that case, I have to clear the textbox before I type another name, but it is possible to remove only letter by letter. When I start removing the whole name, after removing a first letter it acts like I have just entered the name - it selects the item (and focuses as well) - actually there is no time to remove the whole name before it finds a contact again. I have to remove a first letter, then switch back to the textbox, remove another letter etc. Is there any solution for searching to be automatic - as it is now, but on the other hand for removing (clearing the textbox) without selecting contacts to be possible.  </p>
  
  <p>Take a look at the code:</p>
  
  <pre><code>private void txt_Search_TextChanged(object sender, System.EventArgs e)
      {
          if (txt_Search.Text != "")
          {
              foreach (ListViewItem item in listView1.Items)
              {
                  if (item.Text.ToLower().Contains(txt_Search.Text.ToLower()))
                  {
                      item.Selected = true;
                  }
                  else
                  {
                      listView1.Items.Remove(item);
                  }
  
              }
              if (listView1.SelectedItems.Count == 1)
              {
                  listView1.Focus();
              }
          }
          else 
          { 
              LoadContacts();
              RefreshAll();
          }
      } 
  </code></pre>