Handle the PictureBox.Click event:
private void pictureBox1_Click(object sender, EventArgs e)
{
PictureBox p = sender as PictureBox;
if (p != null)
{
OpenFileDialog ofd = new OpenFileDialog();
if (ofd.ShowDialog() == DialogResult.OK)
{
p.Image = Image.FromFile(ofd.FileName);
}
}
}
You may want to restrict the files in the dialog to just Image files, use the Filter property for that.
There is a Tip here which tells you how to get the images-only filter:
A FileDialog.Filter generator for all supported images[
^]