title: How to change datagridview row color based on string value
body: <p>I've tried searching the forums to find the answer, but they all seem to check for an integer value, not a string.
  I've got a C# form pulling data values from an SQL table and displaying them on a datagridview. The column I wish check the string value for is labeled "Type", and is the third column in my data table. I wish to highlight all rows red that contain the word "pharmacy" in the third column. </p>
  
  <pre><code>private void invTableDataGridView_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
      {
          foreach (DataGridViewRow row in invTableDataGridView.Rows)
          {
              if (row.Cells[2].Value.ToString() == "Pharmacy")
              {
                  invTableDataGridView.DefaultCellStyle.BackColor = Color.Red;
              }
          }
  
      }
  </code></pre>
  
  <p>When I run the program with this code, nothing changes, even when I conduct actions that should trigger the databindingcomplete event. Frustratingly, if I change row.Cells[2] to row.Cells[3] where I have integer values, and type </p>
  
  <pre><code>    if (row.Cells[3].Value.ToString() == "0")
  </code></pre>
  
  <p>the code works, but for the wrong column. It only seems to work with integers, but I want it to work with a string. How do I do this?</p>
  
  <p>Edit: Yes, sorry, I should have been consistent. The value I wish to compare to is "Pharmacy", capitalized. </p>
  
  <p>Edit2: Ok I found out why it was giving me so much trouble. The values in column[2] were being added in by a combobox, and for some reason it always adds two spaces after the word even though it does not show the spaces in the string collection editor.</p>