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 from2toform1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2();
f2.f1 = this;//把当前的Form1给form2中的form1对象
f2.Show();
}
/// <summary>
/// 添加名称
/// </summary>
/// <param name="name">名称</param>
public void addname(string name)
{
richTextBox1.Text += name + "\r\n";
}
}
}
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 from2toform1
{
public partial class Form2 : Form
{
public Form1 f1 = new Form1();
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
f1.addname(textBox1.Text.Trim());
}
}
}
public Form1 f1= new Form1();
欢迎光临 苏飞论坛 (http://www.sufeinet.com/) | Powered by Discuz! X3.4 |