110,533
社区成员
发帖
与我相关
我的任务
分享
//FORM1
private void button1_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2(listBox1);
f2.ShowDialog();
}
//FORM2的
public partial class Form2 : Form
{
ListBox lb = new ListBox();
public Form2(ListBox lb)
{
this.lb = lb;
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
lb.Items.Add(textBox1.Text);
this.Close();
}
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 WFTwoForm
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 form2 = new Form2(this.listBox1);
form2.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 WFTwoForm
{
public partial class Form2 : Form
{
private ListBox _listBox;
public Form2(ListBox listBox)
{
_listBox = listBox;
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this._listBox.Items.Add(this.textBox1.Text);
}
}
}