Click here to Skip to main content
15,881,281 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:

hey guy am trying to get an image which is on a picturebox
to get it on another form picturebox.

i got a picturebox on form1 which is pictureBox1
and i got form2 with pictureBox3 and i want the image which is on pictureBox1 to show on PictureBox3 on form2

i have tried this code
pictureBox3.Image.Clone = new Form1.picturebox1.image();
Posted
Comments
Mendor81 3-Dec-12 10:46am    
where does the image come from? if it's from a file then just reload it on the other form.
you could also save it to a temporary image file and reload it this way

1 solution

Create a property on Form2 which sets the Image on it's PictureBox:
C#
public Image Image
   {
   get { return myPictrueBox.Image; }
   set { myPictureBox.Image = value; }
   }
Then set it via the instance of Form2 that you create in Form1:
C#
Form2 f = new Form2();
f.Image = myForm1PictureBox.Image;
f.ShowDialog();
 
Share this answer
 
Comments
Mendor81 3-Dec-12 10:49am    
I would have suggested that one next, should type faster next time ;P

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