How display images in datagridview? c#

前端 未结 3 651
情深已故
情深已故 2020-12-19 10:22

I am developing an application in C # for desktop using Visual Studio Express 2010.

I have a table in MySQL called Products with 3 fields:

ID

3条回答
  •  佛祖请我去吃肉
    2020-12-19 10:50

    Use following Code:

    Bitmap img;
    
    img = new Bitmap(@"c:\images\mousepad.jpg");
    
    // Create the DGV with an Image column
    
    DataGridView dgv = new DataGridView();
    
    this.Controls.Add(dgv);
    
    DataGridViewImageColumn imageCol = new DataGridViewImageColumn();
    
    dgv.Columns.Add(imageCol);
    
    // Add a row and set its value to the image
    
    dgv.Rows.Add();
    
    dgv.Rows[0].Cells[0].Value = img;
    

    Referance LINK .

提交回复
热议问题