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();
            }
     
     
        }
    }
  • 相关阅读:
    JavaScript之链式结构序列化
    js 常用的正则表达式
    99%的人都理解错了HTTP中GET与POST的区别
    取代Promise的Generator生成器函数
    深入了解JavaScript权威指南
    限制input输入类型(多种方法实现)
    textillate.js 文字动画
    jQuery如何改变css伪元素样式
    保存android程序崩溃日志到SD卡
    跟我一起学extjs5(19--模块记录的拖放删除、拖放复制新增)
  • 原文地址:https://www.cnblogs.com/swtool/p/3832379.html
Copyright © 2011-2022 走看看