Hack Forums
[.NET] Opening a Picture from PictureBox1 on Form1 to PictureBox2 on Form2 [VB.NET[ - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Opening a Picture from PictureBox1 on Form1 to PictureBox2 on Form2 [VB.NET[ (/showthread.php?tid=5825294)



Opening a Picture from PictureBox1 on Form1 to PictureBox2 on Form2 [VB.NET[ - Effexion - Apr 15, 2018

I am trying a tarantula keeper's app and want to display the picture a user loads in the 'Add Tarantula' form in the 'My tarantulas' form. I have had a Google around but the queries always seem a little long and vague. Can someone please point me in the right direction please.


RE: Opening a Picture from PictureBox1 on Form1 to PictureBox2 on Form2 [VB.NET[ - Dalvik - Apr 15, 2018

You can pass the Image object through the constructor of Form2.

Code
public class Form2 : Form
{
    public Form2(Image img)
    {
        pictureBox2.Image = img;
    }
}

And you can call it like this:
Code
public void SpawnSecondForm()
{
    Image img = pictureBox1.Image;
    Form2 form = new Form2(img);
    for2.Show();
}



RE: Opening a Picture from PictureBox1 on Form1 to PictureBox2 on Form2 [VB.NET[ - Effexion - Apr 15, 2018

I'm so confused lol. Thanks for the help, though.

Is this C#?


RE: Opening a Picture from PictureBox1 on Form1 to PictureBox2 on Form2 [VB.NET[ - Dalvik - Apr 15, 2018

(Apr 15, 2018 10:44 AM)Effexion Wrote:  I'm so confused lol. Thanks for the help, though.

Is this C#?

Yes but if you know VB.net you should be able to read it. As long as you know how parameters work in VB.net you should have no problems understanding what I said.


RE: Opening a Picture from PictureBox1 on Form1 to PictureBox2 on Form2 [VB.NET[ - Effexion - Apr 16, 2018

(Apr 15, 2018 11:27 AM)Dalvik Wrote:  Yes but if you know VB.net you should be able to read it. As long as you know how parameters work in VB.net you should have no problems understanding what I said.

Yes, you're right. I have been out of practice for so long and wasn't that well-versed to begin with lol. Thanks for your help, sorted it.