0

i place two forms one contain 2 picturebox and 2 button and 2nd form contain 2 picturebox and one button
when insert image in 1st form it automaticaly load on 2nd form when 2nd form load.
plzzzzzzzzzzzzzz help me to do this

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by abelLazm
2

when you show the 2nd form pass the path of loaded image in 2nd form and in form2_load event load that image in picturebox

as

//code in form 1
 String strFileName = "";
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            openFileDialog1.Filter = "Image FIles (*.jpg)|*.jpg|All files (*.*)|*.*";
            //openFileDialog1.InitialDirectory = @"d:/";
            openFileDialog1.Title = "Select an image file"; 
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
                strFileName = openFileDialog1.FileName;
          
            if (strFileName != "")
                pictureBox1.Image = Image.FromFile(strFileName);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Form2 obj = new Form2(strFileName);
            obj.Show();
        }

//code in form 2

 String PathOfImage = "";
        public Form2(String Path)
        {
            InitializeComponent();
            PathOfImage = Path;
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            pictureBox1.Image = Image.FromFile(@PathOfImage);
        }

Edited by abelLazm: n/a

Votes + Comments
Godd Logic
Continous effort.
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.