title: Searching and filtering out results from listbox in visual c#
body: <p>I'm just learning how to code in c# and I'm trying to figure out a way to search and filter out results from a listbox that contains data. Right now I have a listbox and a search button, my listbox contains website history, and my search button finds the item in the list but I cannot find a way to filter out the other items so that only what I searched for in the textbox appears in the listbox. Right now my search button looks like this. Any ideas?</p>
  
  <pre><code>private void searchBtn_Click(object sender, EventArgs e)
  {
      listBoxHist.SelectedItems.Clear();
  
      for (int i = 0; i &lt; listBoxHist.Items.Count; i++)
      {
          if (listBoxHist.Items[i].ToString().Contains(textboxSearch.Text))
          {
              listBoxHist.SetSelected(i, true);
  
          }
      }
  
  }
  </code></pre>