private void btnLogin_Click(object sender, EventArgs e)
{
Form1 frm = new Form1();
frm.Hide();
这里form1没有隐藏,btnLogin在form2中
答案 0 :(得分:7)
试试这个:
// Method in Form1
private void button1_Click(object sender, EventArgs e)
{
Form2 mySecondForm = new Form2(this);
mySecondForm.Show();
}
// This is the second form which you opened from your first form..
public partial class Form2 : Form
{
Form someForm;
public Form2(Form parentForm)
{
InitializeComponent();
someForm = parentForm;
}
private void button1_Click(object sender, EventArgs e)
{
someForm.Hide(); // Form1 should hide now
}
}
希望这会有所帮助。欢呼声。