title: Finding datagridview cell type in C#?
body: <p>i am trying to find each DatagridviewImageCell and set its property <code>ImageLayout</code> to <code>DataGridViewImageCellLayout.Zoom</code> so the image in that cell will be zoomed. I am using this code, but am getting an error: <code>Unable to cast object of type 'System.Windows.Forms.DataGridViewRow' to type 'System.Windows.Forms.DataGridViewImageCell'.</code> here: <code>(DataGridViewImageCell Imgrow in dataGridView1.Rows</code>. This is the code i am using.</p>
  
  <pre><code>                    foreach (DataGridViewImageCell Imgrow in dataGridView1.Rows)
                  {                       
                      if (dataGridView1.Rows[a].Cells[1].Value == "Image")
                      {
                          Imgrow.ImageLayout = DataGridViewImageCellLayout.Zoom;
                      }
                  }
  </code></pre>
  
  <p>How do i fix it? Also, the column is a texbox column, but i am using this to replace the cell.</p>
  
  <pre><code>int a = 0;
  dataGridView1.Rows.Insert(0, 1);
  dataGridView1.Rows[a].Cells["Column1"] = new DataGridViewImageCell();
  dataGridView1.Rows[a].Cells["Column1"].Value = picturebox1.Image; 
  </code></pre>