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); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)