blah blah blah is here! blah blah » Close

up0down
link

Hey,

I'm trying to create a datagridview that contains an image column inside of it but I can't seem to get it right.

I'm getting the datagridview data source from a list and I was wondering how I would get the list image property to be viewed in the datagridview cell.

How can I achieve that?

Thanks.

last answered one year ago

1 answers

up0down
link

If your images are stored in an ImageList which contains an image for each row of the DGV and the images are to be displayed in an image column called "Image" say, then you could display them all using code such as the following:

for(int i = 0; i < dataGridView1.Rows.Count; i++)
{
DataGridViewRow row = dataGridView1.Rows[i];
row.Cells["Image"].Value = imageList1.Images[i];
}

Feedback