Click here to Skip to main content
15,895,836 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all
I write some code to show picture in another form and this code do carefully when I select one picture but I want to select 3 picture and show all of them.
C#
        private void ItmopenMultiplyFiles_Click(object sender, EventArgs e)
{
    openFileDialog1.Multiselect = true;
    openFileDialog1.FileName = string.Empty;
    openFileDialog1.InitialDirectory = @"C:\Users\yonesi\Desktop\Resources";
    openFileDialog1.Filter = "Bitmap Files|*.bmp|jpeg Files|*.jpg;*.jpeg|All Files|*.*";
    openFileDialog1.ShowDialog();
    if (openFileDialog1.ShowDialog() == DialogResult.OK)
    {
        string a = openFileDialog1.FileName;
        string b = Path.GetFileName(a);
        PictureForm frmpic = new PictureForm();
        frmpic.Text = b;
        foreach (string c in openFileDialog1.FileNames)
        {
            frmpic.pictureBox1.Image = Image.FromFile(a);
            frmpic.Show();
        }
    }
}


[edit]Code block added - OriginalGriff[/edit]
Posted
Updated 27-Aug-11 22:13pm
v2

Then you will either need to add PictureBoxes to frmPic, or use multiple instances of frmPic - one for each image:
C#
foreach (string c in openFileDialog1.FileNames)
    {
    MyPictureForm frmpic = new MyPictureForm();
    frmpic.pictureBox1.Image = Image.FromFile(a);
    frmpic.Show();
    }
 
Share this answer
 
C#
{
            openFileDialog1.Multiselect = true;
            openFileDialog1.FileName = string.Empty;
            openFileDialog1.InitialDirectory = @"C:\Users\yonesi\Desktop\Resources";
            openFileDialog1.Filter = "Bitmap Files|*.bmp|jpeg Files|*.jpg;*.jpeg|All Files|*.*";
           
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                foreach (string c in openFileDialog1.FileNames)
                {
                string b = Path.GetFileName(c);
                PictureForm frmpic = new PictureForm();
                frmpic.Text = b
                frmpic.pictureBox1.Image = Image.FromFile(c);
                frmpic.MdiParent=this;
                frmpic.Show();
                }
            }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900