form1和form2,点击form1的label1进入form2的登录界面,在form2中登陆返回结果到form1.
原项目中,重复点击label 或 开启窗体form1 判断有无登陆
因为我有一个V4A(Value4All)供全局调用,所以我没有做额外返回值变量.
public class V4A{
public static bool Islogin;
}
Form2中操作代码
private void Form2_FormClosing(object sender, FormClosingEventArgs e)
{
this.DialogResult = DialogResult.OK;
}
protected override void OnClosing(CancelEventArgs e)
{
base.OnClosing(e);
//this.outvalue = V4A.islogin;
}
Form1:
/*
Form f_login = new Form2();
f_login.MdiParent = this.MdiParent;
f_login.Show(); */
using (Form2 f_login = new Form2())
{
if (f_login.ShowDialog() == DialogResult.OK)
{
if (V4A.islogin)
{
//操作需调用f_login.outvalue;
//operation
}
}
}