I have 2 windowsForms lets call them form1 and form2. form1 consists of a picturebox and a button. When I click on the button form2 opens. Now form2 consists of a grid and depending on the position on which I have clicked on the grid the x and y coordinates are returned to form1. Based on these coordinates I add an image to the pictureBox. But the image isn't getting added! Is there something I am missing here?
Code inside the mouseDownEvent in form2
Form1 f1 = new Form1();
f1.openImage(x,y);
Code in form1
internal void openImage(int x, int y)
{
string ogFileName = "r" + x.ToString() + "c" + y.ToString();
string imageFilePath = ogFileName + "." + extension;
MessageBox.Show(imageFilePath); //I can see the correct path here
pictureBox1.Image = Image.FromFile(imageFilePath);
}//extension is a static variable declared outside this function.