G
Guest
Form1 is a PUBLIC class with a button, a label, and a PUBLIC method called AddText()
Form2 is a PUBLIC class with a button
When Form1.button is pressed it opens Form2 using the Show method
The button on Form2 should execute the AddText() method on Form1 which simply adds some text to the label. I would have thought that I could just write something like this in the Form2 Button_Click event handler
Form1.AddText()
but it doesn't work. I get the following error message if I try to compile
An object reference is required for the nonstatic field, method, or property 'WindowsApplication62.Form1.AddText()
I also tried passing Form1 as part of the constructor for Form2 but it still would not work.
Can anyone shed some light on this
Form2 is a PUBLIC class with a button
When Form1.button is pressed it opens Form2 using the Show method
The button on Form2 should execute the AddText() method on Form1 which simply adds some text to the label. I would have thought that I could just write something like this in the Form2 Button_Click event handler
Form1.AddText()
but it doesn't work. I get the following error message if I try to compile
An object reference is required for the nonstatic field, method, or property 'WindowsApplication62.Form1.AddText()
I also tried passing Form1 as part of the constructor for Form2 but it still would not work.
Can anyone shed some light on this