显示DataGridView中的图像不起作用

时间:2015-11-03 15:53:42

标签: c# datagridview

我想在DataGridView中显示图像(16 * 16px png文件)。每个徽标的路径名称的标题名称是“logo_dom”,我编译了这个,我在每行“System.Drawing.Bitmap”中都有一个文本而不是徽标图片。

var googleApi = "https://sheetsu.com/apis/v1.0/f924526c";
var googleKey = "0123456789";
var googleSecret = "987654321";

var data = [];
$.ajax({
    url: googleApi,
    headers: {
    "Authorization": "Basic " + btoa(googleKey + ":" + googleSecret)
    },
    data: JSON.stringify(data),
    dataType: 'json',
    type: 'GET',

    success: function(data) {

        console.log(data);                      

        var item = data.result.find(function(e){

            return e.name == content;

        }) || data.result[0];           
        console.log("PRINT ID: " + item.id);

        var name = item.name || content;                    
        $('#nameText').text(name);
        console.log("Name: " + name);
});

2 个答案:

答案 0 :(得分:1)

试试这个:

DataGridViewImageColumn column = new DataGridViewImageColumn();
this.dataGridView1.Columns.Add(column);                      
string path = @"D:\LigueStats\Data\Logo\Ligue 1\EST.png";
Image img = Image.FromFile(path);
this.dataGridView1.Rows[0].Cells[0].Value = img;

编辑:

string path = @"D:\LigueStats\Data\Logo\Ligue 1\EST.png";
Image img = Image.FromFile(path);
for (int i = 0; i < dgv_resultats.Rows.Count; i++)
{
    dgv_resultats.Rows[i].Cells["logo_dom"].Value = img;
}

答案 1 :(得分:0)

问题是在datagridview中的列的类型,我问你如何更改加载datagridview的类型

colmunType