zoukankan      html  css  js  c++  java
  • 构造函数实现窗体间传值

    ///Form1.cs  the form contains a textbox and a button
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    
    namespace 窗体间通迅
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                Form2 frm = new Form2(this.textBox1);
                frm.Show();
    
            }
        }
    }
    
    ///Form2.cs  the form contains a textbox and a button
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    
    namespace 窗体间通迅
    {
        public partial class Form2 : Form
        {
            private delegate void dg();
    
            /// <summary>
            /// 让其与窗体1的TextBox1同一个引用。
            /// </summary>
            private TextBox textBox12;
    
            public Form2()
            {
                InitializeComponent();
            }
    
            public Form2(TextBox txtBox)
            {
                InitializeComponent();
                textBox1.Text = txtBox.Text; ;
                this.textBox12 = txtBox;
                
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                textBox12 .Text  = textBox1.Text;
                this.Close();
                
            }
        }
    }
  • 相关阅读:
    思考-少写代码
    app上传 那些事儿!
    vs2010 找不到本地服务器
    如何成为一名优秀得程序员
    python成功之路,Day2-判断和循环语句
    python成功之路,Day1-发展历史
    ES6学习笔记2-字符串扩展
    ES6学习笔记1-解构赋值
    数组的方法
    ES6
  • 原文地址:https://www.cnblogs.com/hbhbice/p/1725037.html
Copyright © 2011-2022 走看看