Form2访问form1的控件,两段差不多的代码,结果不一样呢
在form2的button事件中:
Button con = (((this.Owner) as Form1).Controls["button6"]) as Button;
string str = (sender as Form).Text.Substring(0, 2);
con.Text = str;
ComboBox con = (((this.Owner) as Form1).Controls["comboBox1"]) as ComboBox;
string str = (sender as Form).Text.Substring(0, 2);
con.Text = str;
两段看似差不多的代码,为什么下面那个combobox会报错,:未将对象引用设置到对象的实例
而上面的不报错?