'How to call Form 1's method from Form2 without static and new class();?

How to call Form 1's method when Form is resized without static and new class(); like below codes. because more than one new class(); The "System.StackOverflowException" issue is causing when the code is used. it does not take the values it saves in the class due static.

Form1 class code:

Form2 frm2 = new Form2();
public void ResizePicture(int Height, int Width)
{
    frm2.pictureBox1.Height = Height;
    frm2.pictureBox1.Width = Width;
}

private void button1_Click(object sender, EventArgs e)
{
    frm2.pictureBox1.Image = Image.FromFile(@"C:\Users\Omer\Desktop\screenshot.png");
    frm2.Show();
}

Form2 class code:

private void Form2_Resize(object sender, EventArgs e)
{
    ResizePicture(this.Height, this.Width);
}


Solution 1:[1]

Another one, passing Form1 via Show() itself:

private void button1_Click(object sender, EventArgs e)
{
    frm2.pictureBox1.Image = Image.FromFile(@"C:\Users\Omer\Desktop\screenshot.png");
    frm2.Show(this); // <-- passing Form1 here!
}

In Form2, you cast .Owner back to Form1:

private void Form2_Resize(object sender, EventArgs e)
{
    Form1 f1 = (Form1)this.Owner;
    f1.ResizePicture(this.Height, this.Width);
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Idle_Mind