在C#中更新DatagridView图像列

问题描述

我正在尝试更新由数据表填充的datagridview。

启动时显示的是(Properties.Resources.database)的图像,而不是(Properties.Resources.completed)的图像。

        DataTable dtStores = new DataTable();
        dtStores.Columns.Add("Total");
        dtStores.Columns.Add("Store");
        dtStores.Columns.Add("Status",typeof(Image));

        DaTarow rStore = dtStores.NewRow();
        rStore["Total"] = "";
        rStore["Store"] = "Supermarket";
        rStore["Status"] = Properties.Resources.database;
        dtStores.Rows.Add(rStore);

        dataGridView1.DataSource = dtStores;
        
        DataGridViewRow dGRVStore = dataGridView1.Rows[0];

        DataGridViewImageCell imgStatus = new DataGridViewImageCell();

        imgStatus.Value = Properties.Resources.completed;
        dGRVStore.Cells["Status"] = imgStatus ; dataGridView1.Refresh();

解决方法

dataGridView1 [“状态”,0] .Value = Properties.Resources.completed;

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...