C# - How to make two forms reference each other

前端 未结 6 1592
忘了有多久
忘了有多久 2020-11-29 12:16

I\'m writing a WindowsForms application in MS Visual C#, and I need two forms to be able to reference each other. As I test, I created two buttons on Form1 -- one button tha

6条回答
  •  天涯浪人
    2020-11-29 13:21

    You're creating a new instance of each form as you create the other form.

    Instead, you should make one of the forms take an instance its parent form as a parameter.

提交回复
热议问题