I've used a datagridview many times in the past without any issues, but this is the first time I am trying to display an image in one and I'm coming across an issue that I could use some help with.
The datagridview only has 2 columns associated with it. One for the actual image, and one for the path that indicates where the images exists.
Here is the code that I am using to load images into a datagridview:
private void ViewImages_Load(object sender, EventArgs e)
{
// if item id is not empty, add it to the form title
if (string.IsNullOrEmpty(sItemID) == false)
this.Text = this.Text + sItemID;
int iCell = 0;
// get all the files that exist for the item so we can display them on the screen
string[] files = System.IO.Directory.GetFiles(SelectedImagePath, "[Image]." + sItemID + "_*.jpg");
foreach (string s in files)
{
dataGridView1.Rows.Add(Bitmap.FromFile(s), s);
dataGridView1.Rows[iCell++].Height = 500; // make cell height bigger
}
}
The first time I load this form I don't encounter an error, but the second time I try to load this form , I get an out of memory error.
I am only trying to populate this datagridview with < 10 images.
Can anyone assist me with figuring how what needs to be done to resolve this issue ?
T U !
The datagridview only has 2 columns associated with it. One for the actual image, and one for the path that indicates where the images exists.
Here is the code that I am using to load images into a datagridview:
private void ViewImages_Load(object sender, EventArgs e)
{
// if item id is not empty, add it to the form title
if (string.IsNullOrEmpty(sItemID) == false)
this.Text = this.Text + sItemID;
int iCell = 0;
// get all the files that exist for the item so we can display them on the screen
string[] files = System.IO.Directory.GetFiles(SelectedImagePath, "[Image]." + sItemID + "_*.jpg");
foreach (string s in files)
{
dataGridView1.Rows.Add(Bitmap.FromFile(s), s);
dataGridView1.Rows[iCell++].Height = 500; // make cell height bigger
}
}
The first time I load this form I don't encounter an error, but the second time I try to load this form , I get an out of memory error.
I am only trying to populate this datagridview with < 10 images.
Can anyone assist me with figuring how what needs to be done to resolve this issue ?
T U !