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("world.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;
Thanks alot.. It is useful for me after a long time struggle with it. GBU.
ReplyDeleteYou are welcome!
DeleteI have a picturebox which I am using a browse button to get the picture. What can i do to get it from there since i am going to use a different picture all the time ?
ReplyDeleteThanks
In that case, you need to get the picture from your picture Box and assign that to 'image_Form1' variable and then transfer that image as usual using 'Image_Form1' property.
Deleteimage_Form1 = pictureBox1.Image;
Here is the piece of code for your reference:
private void btn_Browse_Click(object sender, EventArgs e)
{
DialogResult r = openFileDialog1.ShowDialog();
if (r == System.Windows.Forms.DialogResult.OK)
{
pictureBox1.Image = Image.FromFile(openFileDialog1.FileName);
}
image_Form1 = pictureBox1.Image;
}
Hope it will help.
It worked on my project. Thank for your useful post :).
ReplyDeleteI was reflecting recently on the mindsets of several friends and acquaintances that seem to be willing to sacrifice their self-worth for the uncertainty of their net-worth. Why would I say uncertainty in the previous Quavo Net Worth I don't care how much money you have in the bank, CD's, your retirement fund or any other equity in other sources - nothing in the future is ever totally secure which I'm sure some of you have already discovered.
ReplyDeletethankssss nso much help
ReplyDelete