首先在 Form1写如下代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace _2
{
public partial class Form1 : Form
{
public static Form1 pForm1 = null;
public Form1()
{
pForm1 = this;
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e) //一个按钮控件的单击事件
{
Form2 frm2 = new Form2();
frm2.Show();
this.Hide();
}
}
}
然后在Form2中加下面代码就行了
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace _2
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
//关闭Form2时显示Form1
private void Form2_FormClosed(object sender, FormClosedEventArgs e)
{
Form1.pForm1.Show();
}
}
}
温馨提示:答案为网友推荐,仅供参考