zoukankan      html  css  js  c++  java
  • C# 两个窗体中相互切换的方法

    注意将form2中的botton2的modyfier属性修改为public

    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 test
    {
        public partial class Form1 : Form
        {
            Form2 frm = new Form2();
            public Form1()
            {
                InitializeComponent();
            }
     
            private void button1_Click(object sender, EventArgs e)
            {
                this.Hide();          
                frm.Show();
                frm.button2.Click +=button2_Click;
            }
            private void button2_Click(object sender, EventArgs e)
            {
                MessageBox.Show("form1");
                this.Show();
            }
     
            private void Form1_Load(object sender, EventArgs e)
            {
     
            }
        }
    }

    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 test
    {
        public partial class Form2 : Form
        {
            public Form2()
            {
                InitializeComponent();
            }
     
            private void button2_Click(object sender, EventArgs e)
            {
                MessageBox.Show("form2");
                this.Hide();
            }
     
     
        }
    }
  • 相关阅读:
    2008年秋季毕业设计总体安排
    2008秋季计算机软件基础0903课堂用例(1)
    收藏:微软新技术不断,开发者如何面对?
    2008秋季计算机软件基础0901课堂用例
    2008秋季计算机软件基础0908课堂用例(1)
    WebBrows仿造Cookie
    ScriptCase价格调整通知
    JavaMail API简介
    Spring攻略学习笔记(3.05)重用切入点定义
    verletjs:超酷的开源JavaScript物理引擎
  • 原文地址:https://www.cnblogs.com/swtool/p/3832379.html
Copyright © 2011-2022 走看看