0

I have a form with OpenFileDialog for selecting image and showing it in pictureBox. Until the form is open the user can open and then save the opened image as many times as he wants.But when he secont time open openfiledialog the picture show but the both image show in same location,
I want the picture not show in same location,Please tell me the location of image.

 private void button1_Click(object sender, EventArgs e)
        {
            PictureBox pic = new PictureBox();
            {
                try{
  OpenFileDialog open = new OpenFileDialog();
  open.Title = "OPen Image";
   // open.Filter = "PNG image (*.png)|*.png|Jpg image (*.jpg)|*.jpg|";
  open.Filter = "JPG Files (*.jpg)|*.jpg|JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|GIF Files (*.gif)|*.gif";
    DialogResult result = open.ShowDialog();
     if (result == DialogResult.OK)
      {

     pic.Image = new Bitmap(open.FileName);
        pic.SizeMode = PictureBoxSizeMode.AutoSize;
     listView1.Controls.Add(pic);
   }   
     }
     catch (Exception ex)
 {
   // Could not load the image - probably related to Windows file system permissions.
    MessageBox.Show("Cannot display the image: " + ex.Message);
           }
     }
    }
2
Contributors
1
Reply
11
Views
10 Months
Discussion Span
Last Post by ddanbe
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.