-1

This question already has an answer here:

I tried to search about it but i'm getting about saving to bitmap, or get the image from file something like that. That's why i asked it here. I have two pictureboxes. First picturebox is on form 1 and 2nd picturebox is on form 2. In picturebox 2, I'm capturing image using my webcam and put it to these picturbox, My problem is i want to get that picture and fill it to picturebox 1. How I'm gonna do that?

private void btn_save_Click(object sender, EventArgs e)
{
    view.Picture = pictureBox2;
    this.Close();
}

NOTE:

  • Picture // Picturebox1 from form 1 I'm accessing these object
  • pictureBox2 // from my form 2 which is opened by a button in form 1
  • this btn_save is from my form 2 if i click this, it should save the image from Picture


  • Very unclear. You probably don't know how to access elements on one form from another? This is being asked 10-20 times every day.. - You need a reference to the original and visible instance. Best pass in in the constructor of the 2nd form! See here for a few ways to do that.. - TaW

1 답변


1

Just make the PictureBox on the form public and then:

picturebox1.Image = form2.picturebox2.Image;

Just open Form1.Designer.cs (assuming form name is Form1), find the Line that picturebox is defined and set it public. It must be something like this in the in the end of the file:

private System.Windows.Forms.PictureBox picturebox1; 

change it to

public System.Windows.Forms.PictureBox picturebox1; 

Linked


Related

Latest