DataGridView图像列将为空。代码如下;
public partial class ReadingOrderListControl : UserControl
{
private Image Pending { get { return Image.FromFile(@"..\..\Resources\pending.png"); } }
private Image Completed { get { return Image.FromFile(@"..\..\Resources\completed.png"); } }
private void ReadingOrderListControl_Load(object sender, EventArgs e)
{
GetOrderList();
}
private void GetOrderList()
{
dgv_ReadingOrders.DataSource = DbManager.GetReadingOrders();
if (dgv_ReadingOrders.Rows[0].Cells["tamamlanma"].Value.ToString() == "1")
dgv_ReadingOrders.Rows[0].Cells["tamamlanma_image"].Value = Completed;
else
dgv_ReadingOrders.Rows[0].Cells["tamamlanma_image"].Value = Pending;
}
}
答案 0 :(得分:0)
尝试一下:
if (dgv_ReadingOrders.Rows[0].Cells["tamamlanma"].Value.ToString() == "1")
dgv_ReadingOrders.Rows.Add(ID,...... , Bitmap.FromFile(Completed));
else
dgv_ReadingOrders.Rows.Add(ID,...... , Bitmap.FromFile(Pending));