if子句在datagridviewimagecolumn中使用image

是否可以使用datagridviewimage列中的图像设置IF大小写?
Example:
If current row image = "Red.png"... show error msg  
If current row image = "Green.png"... Insert to database
谢谢!     
已邀请:
你可以用这种方式实现这一目标 需要指定一个Text来标识您在DataGridViewImageCell中显示的图像,同时添加图像只需设置该单元格的描述
(dataGridView1[2, 2] as DataGridViewImageCell).Description = "Red";// Or Green
然后当你循环检查imagecell的描述并做你的东西
foreach (DataGridViewRow row in dataGridView1.Rows)
{
  if(row.Cells[2] is DataGridViewImageCell)
  {
     if((row.Cells[2] as DataGridViewImageCell).Description == "Red")
     { // your stuff}
  }
}
    

要回复问题请先登录注册