How to pass only image from 1 windows form to another window?
how to pass only image from 1 windows form to another window form without need of image path and using of constructor in c sharp
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Hemant SrivastavaPosted Jul 30, 2012, 2:34 PM
Step-1: Add a following reference to your project:
Sytem.Drawing
Step-2: Make a property as following in one of your Form (say Form1) so that this property would be accessible to another form (say Form2)
Image image_Form1;
public Image Image_Form1
{
get { return image_Form1; }
set { image_Form1 = value; }
}
Step-3: Then in your code get the image in a variable (say image_From1)
image_Form1= Image.FromFile("yourImage.bmp");
Step-4: In your another form "Form2", suppose you want to show the Form1's image in a picture Box.
Make an object of Form1 in Form2.
Form1 Form1Object = new Form1();
Step-5: Then you could assign Form1's image to a picture Box like:
pictureBox.Image = Form1Object.Image_From1;
If the above code helps, Pls make it accepted.