title: Searching in datagridview using c#
body: <p>After loading a table in datagridview I'm generating a combobox's items from the datagrid column headers. From the combobox I am selecting the column and I have a textbox for the search value given by user. I'm using the following code:</p>
  
  <pre><code>        string searchForText = txtCrudSearch.Text;
          dgvLoadTable.ClearSelection();
          dgvLoadTable.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
          try
          {
              foreach (DataGridViewRow row in dgvLoadTable.Rows)
              {
                  if (row.Cells[cboCrudSearchColumn.SelectedIndex].Value.ToString().Equals(searchForText))
                  {
                      row.Selected = true;
                      //if I use break here the code doesn't give exception 
                      //but highlights only one row. I want to return all rows that
                      // match with the search string
                  }
              }
          }
          catch (Exception ex)
          {
              MessageBox.Show(ex.Message);
          }
  </code></pre>
  
  <p>Now , the problems are:</p>
  
  <ol>
  <li>I get all matched rows highlighted with the exception "Object reference not set to an instance of the object"</li>
  <li>How can I return all the matching rows only in the datagrid instead of highlighting them?</li>
  <li>The search is case sensitive, how to make it work for all types?</li>
  </ol>
  
  <p>Any help will be appreciated, thanks.</p>