111,120
社区成员
发帖
与我相关
我的任务
分享
//FORM1的代码
Form2 frm2;
private void Form1_Load(object sender, EventArgs e)
{
frm2 = new Form2();
if (frm2.ShowDialog() == DialogResult.OK)
{
MessageBox.Show(frm2.textBox1.Text);
}
}
//FORM2的代码
private void button1_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.OK;
}
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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Form2 frm2;
private void Form1_Load(object sender, EventArgs e)
{
frm2 = new Form2();
frm2.Show();
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(frm2.textBox1.Text);
}
}
}