检测datagridview图片列是否有默认图片
Detect whether the datagridview image column has the default image
我有一个带有图像列的数据网格视图,此列的空值在设计器中自动设置为 System.Drawing.Bitmap
。
现在,从后面的代码中,我需要检查该列显示的是默认图像还是其他图像,以便在图片框中显示它。
为此,我尝试使用以下代码。
If Not dgImageList.CurrentRow.Cells("img1").Value Is Nothing Then pctBox.BackgroundImage = dgImageList.CurrentRow.Cells("img1").Value
我建议您使用另一列来执行该比较。任何布尔值 属性(例如:"return image is null")、图片名称或类似内容。
因为如果我理解了你的问题,你的标题可能是"Compare two images"。然后,"reinvent" 没什么:
Compare two images to check if they are the same
我有一个带有图像列的数据网格视图,此列的空值在设计器中自动设置为 System.Drawing.Bitmap
。
现在,从后面的代码中,我需要检查该列显示的是默认图像还是其他图像,以便在图片框中显示它。
为此,我尝试使用以下代码。
If Not dgImageList.CurrentRow.Cells("img1").Value Is Nothing Then pctBox.BackgroundImage = dgImageList.CurrentRow.Cells("img1").Value
我建议您使用另一列来执行该比较。任何布尔值 属性(例如:"return image is null")、图片名称或类似内容。
因为如果我理解了你的问题,你的标题可能是"Compare two images"。然后,"reinvent" 没什么: Compare two images to check if they are the same