The code you provided in your last post should definitely go in Form2 because a) it has no bearing whatsoever on the functionality of Form1, and b) it is specific to a control on Form2.
Unless I'm missing something, you would...
1. Add the following property to Form1 (in your form global variables list):
static string targetFileName {get; set;}
* doing this makes accessing the value from Form2 much easier and less prone to weird behavior
2. Change the following method in Form1 as shown:
#region Full Image Popup
private void listView1_DoubleClick(object sender, EventArgs e)
{
Point pt = listView1.PointToClient(Cursor.Position);
ListViewItem lvi = listView1.GetItemAt(pt.X, pt.Y);
if (lvi != null)
{
targetFileName = (string)lvi.Tag;
frm.Text = lvi.Text;
frm.Show();
}
}
#endregion
3. Add the following line to the end of the Form2 constructor:
ShowFile(Form1.targetFileName);
4. Change the ids for "pb" in your last post to "pictureBox1".
5. Make sure you do a string.IsNullOrEmpty(Form1.targetFileName) before using targetFileName in your code... otherwise you might get an exception if the property is ever empty or null.
6. Make sure you add a "break;" after "pb.Controls.Add(tempPicturebox);" in your last post... otherwise, the loop will continue even after it's made the correct file match.
That should do it.