主窗口后台代码:
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 WindowsFormsApplication2{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } //建立集合来记录 List
弹出窗口的后台代码:
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 WindowsFormsApplication2{ public partial class Form2 : Form { Form1 F1 = null; public Form2(Form1 f1, string uname) { InitializeComponent(); F1 = f1; label1.Text = uname + ",欢迎回来!"; } private void Form2_FormClosing(object sender, FormClosingEventArgs e) { F1.RemoveForm(this); } }}