I have 3 picture boxes which hold an image from a list string. There is a button which goes through each element in the list string, which in turn updates the 3 picture boxes the picture boxes that hold the 3 images are, picturebox3, 4 and 5. i have added a mouse event that triggers once the mouse is on the image to expand the image in another picturebox which is hidden until the mouse is on top of it. i created 3 extra pictureboxes which are pictureBox6, 7 and 8 to show the enlarged image which relate to picturebox3, 4 and 5. picturebox 6 is related to 3, picturebox 7 is related to 4 and 8 is related to 5. I have tried to set the picturebox to null after the mouse is off the image however that hasn’t worked. Below is the code for the image in picturebox 3, 4 and 5 to be updated as it goes through the list it also includes the event triggers.
download_file_names[] = the filename ".jpg" matching_image_for_Processing[intIndex] = the folder which holds the file
Those variables above do change as i go through the list so i know that works
I have tried to set the picturebox to null after the mouse is off the image however that hasnt worked.
Below is the code for the image in picturebox 3, 4 and 5 to be updated as it goes through the list it also includes the event triggers.
if (download_file_names.ElementAtOrDefault(0) != null)
{
pictureBox3.Image = new Bitmap(Environment.CurrentDirectory + "\\" + "temp_data" + "\\" + matching_image_for_Processing[intIndex] + "\\" + download_file_names[0]);
pictureBox3.MouseHover += new EventHandler((sender2, e2) => pictureBox3_Mouse(sender2, e2, download_file_names[0], matching_image_for_Processing[intIndex]));
pictureBox3.MouseLeave += new EventHandler(pictureBox3_MouseLeave);
}
else
{
pictureBox3.Image = new Bitmap(Environment.CurrentDirectory + "\\" + "NoImage.bmp");
}
if (download_file_names.ElementAtOrDefault(1) != null)
{
pictureBox4.Image = new Bitmap(Environment.CurrentDirectory + "\\" + "temp_data" + "\\" + matching_image_for_Processing[intIndex] + "\\" + download_file_names[1]);
pictureBox4.MouseHover += new EventHandler((sender2, e2) => pictureBox4_Mouse(sender2, e2, download_file_names[1], matching_image_for_Processing[intIndex]));
pictureBox4.MouseLeave += new EventHandler(pictureBox4_MouseLeave);
}
else
{
pictureBox4.Image = new Bitmap(Environment.CurrentDirectory + "\\" + "NoImage.bmp");
}
if (download_file_names.ElementAtOrDefault(2) != null)
{
pictureBox5.Image = new Bitmap(Environment.CurrentDirectory + "\\" + "temp_data" + "\\" + matching_image_for_Processing[intIndex] + "\\" + download_file_names[2]);
pictureBox5.MouseHover += new EventHandler((sender2, e2) => pictureBox5_Mouse(sender2, e2, download_file_names[2], matching_image_for_Processing[intIndex]));
pictureBox5.MouseLeave += new EventHandler(pictureBox5_MouseLeave);
}
else
{
pictureBox5.Image = new Bitmap(Environment.CurrentDirectory + "\\" + "NoImage.bmp");
}
below is the code for the other picturesboxes to display the larger image.
void pictureBox3_Mouse(object sender, EventArgs e, string catching, string catching2)
{
pictureBox6.Visible = true;
pictureBox6.Image = new Bitmap(Environment.CurrentDirectory + "\\" + "temp_data" + "\\" + catching2 + "\\" + catching);
Console.WriteLine("temp_data" + "\\" + catching2 + "\\" + catching);
pictureBox6.Refresh();
}
void pictureBox3_MouseLeave(object sender, EventArgs e)
{
pictureBox6.Visible = false;
pictureBox6.Image = null;
pictureBox6.Refresh();
}
void pictureBox4_Mouse(object sender, EventArgs e, string catching_1, string catching2_1)
{
pictureBox7.Visible = true;
pictureBox7.Image = new Bitmap(Environment.CurrentDirectory + "\\" + "temp_data" + "\\" + catching2_1 + "\\" + catching_1);
pictureBox7.Refresh();
}
void pictureBox4_MouseLeave(object sender, EventArgs e)
{
pictureBox7.Visible = false;
pictureBox7.Image = null;
pictureBox7.Refresh();
}
void pictureBox5_Mouse(object sender, EventArgs e, string catching_2, string catching2_2)
{
pictureBox8.Visible = true;
pictureBox8.Image = new Bitmap(Environment.CurrentDirectory + "\\" + "temp_data" + "\\" + catching2_2 + "\\" + catching_2);
pictureBox8.Refresh();
}
void pictureBox5_MouseLeave(object sender, EventArgs e)
{
pictureBox8.Visible = false;
pictureBox8.Image = null;
pictureBox8.Refresh();
}
I am hoping someone can help me solve this issue, as i go to the next element in the list and hover over the new image i keep getting the error Parameter is not valid. i believe the picturebox is holding the previous variable.