title: C# I have a list of <Person>objects in a dataGridView. How can this be searched by a user inputing text into a txt box input?
body: <p>I have a list of <code>Person</code> objects that contain the variables <code>{int id, string name, string status, int age}</code>. How can this be searched by a user inputting text into a text box?</p>
  <p>I have the list of <code>Person</code> in a binding list attached to a <code>dataGridView</code>.  I would like to search the <code>dataGridView</code> for a person's name or age, or any of the variables and to return a list of all the rows that contain information found.  This is what I have now.</p>
  <pre class="lang-cs prettyprint-override"><code>BindingList&lt;Person&gt; foundPerson = new BindingList&lt;Person&gt;();
  bool found = false;
  if (txt_PeopleSearch.Text != null)
  {
      for (int i = 0; i &lt; foundPerson.Count; i++)
      {
          if 
          (foundPerson[i].ToString().ToUpper().Contains
          (txt_PeopleSearch.Text.ToUpper()))
          {
              foundPerson.Add(foundPerson[i]);
              found = true;
          }
      }
      if (found)
      {
          dgvPerson.DataSource = foundPart;
      }
      if (!found)
      {
          MessageBox.Show(&quot;No People match your search&quot;);
          dgvPerson.DataSource = foundPerson;
      }
  }
  </code></pre>