c#2个窗口关联

来源:互联网 发布:淘宝货品下架后再上架 编辑:程序博客网 时间:2024/05/06 05:17
Form1:代码


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;


namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        private void button2_Click(object sender, EventArgs e)
        {
            Form2 f = new Form2(this);
            f.Show();
        }


    }
}


Form2代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;


namespace WindowsApplication1
{
    public partial class Form2 : Form
    {
        Form1 f =null;
        public Form2(Form1 f)
        {
            InitializeComponent();
            this.f = f;

        }

   }

}

原创粉丝点击