title: cannot implicitly convert type string to System.Windows.Forms.Datagridviewcell c#
body: <p>I am trying to do something like if there is a selection from a drop downbox it should make a change in color to the Datagridview row.</p>
  
  <p>I have used switch case, doent change nothing, hence I wanted to use another approach to it. Code looks like this</p>
  
  <pre><code>private void RowsColor()
  {
      try
      {
          for (int i = 0; i &lt; dataGridView1.Rows.Count; i++)
          {
              if (dataGridView1 != null)
              {
                  if (dataGridView1.Rows != null)
                  {
                      if (dataGridView1.Rows[i].Cells != null)
                      {
                          if (dataGridView1.Rows[i].Cells[11] != null)
                          {
                              //string val = dataGridView1.Rows[i].Cells[11].Value.ToString();
                              var val = dataGridView1.Rows[i].Cells[11];
                              if (val = "Confirm Appointment")
                              {
                                  dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                              }
                              else if (val = "Reschedule")
                              {
                                  dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.Yellow;
                              }
                          }
                      }
                  }
              }
          }
      }
      catch(Exception ex)
      {
          MessageBox.Show(ex.ToString());
      } 
  }
  </code></pre>
  
  <p>Now I am getting something like this as an error </p>
  
  <blockquote>
    <p>cannot implicitly convert type string to
    System.Windows.Forms.Datagridviewcell</p>
  </blockquote>
  
  <p>New to this, What exactly am I missing?</p>