-2
private void btn_justest_Click(object sender, EventArgs e)
{           
    using (var myForm = new FormShowResult())
    {
        myForm.Show();
        textBoxNameTest.Text = FormShowResult.TheValue;
    }
}

in Form 2:

public string TheValue
{
    get { return richtb_Show.Text; }
}

the problem is there is error "An object reference is required for the non-static field, method, or property" how to solve

My purpose to is call set an value to the parameter of Form2's Function, and load the function when start Form2.

Lam Weng
  • 1
  • 2

2 Answers2

2

You need to use the myForm variable to access the instance, not the type name.

Jason Watkins
  • 3,766
  • 1
  • 25
  • 39
2
  textBoxNameTest.Text = myForm.TheValue;
d.moncada
  • 16,900
  • 5
  • 53
  • 82