C#中用到的窗体传值技术
C#中用到的窗体传值技术

具体的传值示例代码:

Form3的代码

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 winForm窗体间相互传值
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }


        public string TextBox1Value
        {
            set { txtForm3.Text = value; }
            get { return txtForm3.Text; }
        
        }
        private void Form3_Load(object sender, EventArgs e)
        {

        }

        private void btnForm3_Click(object sender, EventArgs e)
        {
            Form4 f4 = new Form4();
            f4.U4 = txtForm3.Text.Trim();
            f4.Show(this);
        }
    }
}

Form4 的代码

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 winForm窗体间相互传值
{
    public partial class Form4 : Form
    {
        public Form4()
        {
            InitializeComponent();
        }


        public string U4 { get; set; }
        private void button1_Click(object sender, EventArgs e)
        {
            Form3 f3 = (Form3)this.Owner;
            f3.TextBox1Value = txtForm4.Text;
            //this.Close();
        }

        private void Form4_Load(object sender, EventArgs e)
        {
            txtForm4.Text = U4;


        }
    }
}

相关文章:

  • 2021-09-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-19
  • 2022-01-08
猜你喜欢
  • 2021-11-28
  • 2021-10-20
  • 2021-12-11
  • 2021-11-05
  • 2022-12-23
  • 2021-09-24
  • 2022-03-04
相关资源
相似解决方案