两个winform窗体之间的传值

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-1 10:55   408   0

窗体一的代码:

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 name
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{

Form2 f = new Form2(textBox1.Text,textBox1.Text);
f.Show();

}
}
}

窗体二的代码:

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 name
{
public partial class Form2 : Form
{
string s = null;
public Form2(string str,string i)
{
InitializeComponent();
this.s = str;
label1.Text = s+i;
}
}
}

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP