如何在Windows窗体应用程序中将图像从文件夹加载到datag

如何在Windows窗体应用程序中将图像从文件夹加载到datag

本文介绍了如何在Windows窗体应用程序中将图像从文件夹加载到datagridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在windows窗体中将图像从文件夹加载到datagridview,gridview应该有一个复选框来选择每个图像。



提前谢谢

I need to load image from a folder to datagridview in windows form, the gridview should have a check box to select each image.

Thanks in advance

推荐答案

private void dataGridView1_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
       {

           OpenFileDialog dlg = new OpenFileDialog();
           DialogResult dr = dlg.ShowDialog();
        if (dr == System.Windows.Forms.DialogResult.OK)
        {
            string filename = dlg.FileName;
            ((DataGridViewImageCell)dataGridView1.Rows[e.RowIndex].Cells[1]).Value = Image.FromFile(filename);
        }

       }


这篇关于如何在Windows窗体应用程序中将图像从文件夹加载到datagridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 03:06