求助:如何保持两个checkbox的checkstate属性一致?急!
假如checkbox1和checkbox2控件分别在窗体form1和form2上,点击form1上的button1按钮进入form2界面,代码如何写才能保持checkbox1和checkbox2的checkstate属性一致?
我新手,不太会写代码,望高手指点,急!
[ 本帖最后由 nanxinda88 于 2009-9-7 15:21 编辑 ]
public CheckState CBCheckState { get { return this.checkBox2.CheckState; } set this.checkBox2.CheckState = value; } }然后双击Form1中的Button1:
Form2 form2 = new Form2(); form2.Load += new EventHandler(form2_Load); form2.Show();在添加form2.load相应方法:
void form2_Load(object sender, EventArgs e) { (sender as Form2).CBCheckState = this.checkBox1.CheckState; }