Click here to Skip to main content
15,894,460 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I'm using paths to retrieve images that will be displayed in a DataGridView. If I load one image, it's fine, if I try to load 2 or more images, only the last one gets displayed in the DataGridView. Any idea why this is happening?
thanks

DataGridViewImageColumn iconColumn = new DataGridViewImageColumn();
dataGridView2.Columns.Insert(0, iconColumn); 
dataGridView2.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders;
dataGridView2.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCellsExceptHeader;
dataGridView2.Rows[0].Cells[0].Value = (Image)Bitmap.FromFile(@"C:\Documents and Settings\mbazinet\My Documents\Mathieu\Plans\Plans\Images\porteA_35.jpg");
dataGridView2.Rows.Add();
dataGridView2.Rows[1].Cells[0].Value = (Image)Bitmap.FromFile(@"C:\Documents and Settings\mbazinet\My Documents\Mathieu\Plans\Plans\Images\porteB_35.jpg");
dataGridView2.Rows.Add();
dataGridView2.Rows[2].Cells[0].Value = (Image)Bitmap.FromFile(@"C:\Documents and Settings\mbazinet\My Documents\Mathieu\Plans\Plans\Images\porteC_35.jpg");
dataGridView2.AutoResizeRows(DataGridViewAutoSizeRowsMode.DisplayedCells); 
Posted
Updated 2-Jul-11 14:12pm
v2

1 solution

check datagridview properties "AllowUserToAddRows" if it set "True" then set "False"


hope this help
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900