日期:2014-05-20  浏览次数:20880 次

2个winform之间
我要在winform1的closing事件中将winform2的button1的enable设置为true,请问语句怎么写?给点代码参考一下,麻烦各位大侠帮忙,急着交作业,谢

------解决方案--------------------
public Form1(Form form)
{}


Form1 form1 = new Form1(form2);


form2.Button1.Enabled = true;


------解决方案--------------------
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
Form1 f1=new Form1;
f1.FormClosed += new FormClosedEventHandler(Form1_FormClosed);
f1.ShowDialog();
}

void f1_FormClosed(object sender, FormClosedEventArgs e)
{
this.button1.Enabled = true;
}
}
------解决方案--------------------
樓上方法正解
------解决方案--------------------
在窗體設計器中定義
Dim frm As Form2
Public Sub New(ByVal vFrmstock As Form2)
MyBase.New()
InitializeComponent()
frm = vFrmstock
End Sub


在FormClosing事件中調用
frm.Button1.Enabled = True