在winform中打開的子窗口獲取父窗口時,需要通過name來獲取屬性,比如text屬性,需要通過構建父窗口的函數來實現。
1、在父窗口(MainViewContent)中(MainViewContent.cs)定義新的窗口變量:

然后在父窗口的函數中中添加
mainViewContent=this;
2、將需要調用的控件屬性在MainViewContent.Desihner.cs中修改為public。
3、在子窗口中調用控件,使用MainViewContent.mainViewContent.控件名稱.屬性
