??????ó??????У??????????????????????????д????????????????????????????£?

??????????Form1?????ListBox???????????????????????Form2??Form2????????????????TextBox???????е???е??????????????????????????????????????Form1???????????е????????Form2????
??????????????
???????????Form2???????н??????string????????????Form1??????е????????Form2??TextBox?????Text???????string?????????Form1??Form2????????Form2??AcceptChange??????£???????Form1??ListBox??????е?????????????????Form1?е?ListBox??????????????Form2????????????????Form2??????????????·??Form2???????£?
publicpartial class Form2 : Form
{
private string text;
private ListBox lb;
private int index;
//??????????????????????????????ListBox??????????????
public Form2(string text??ListBox lb??int index)
{
this.text = text;
this.lb = lb;
this.index = index;
InitializeComponent();
this.textBox1.Text = text;
}
private void btnChange_Click(object sender?? EventArgs e)
{
string text = this.textBox1.Text;
this.lb.Items.RemoveAt(index);
this.lb.Items.Insert(index?? text);
this.Close();
}
}
????Form1??new????2????д??
public partial class Form1 :Form
{
int index = 0;
string text = null;
public Form1()
{
InitializeComponent();
}
private void listBox1_SelectedIndexChanged(object sender?? EventArgse)
{
if (this.listBox1.SelectedItem != null)
{
text = this.listBox1.SelectedItem.ToString();
index = this.listBox1.SelectedIndex;
//????Form2?????????
Form2 form2 = new Form2(text?? listBox1?? index);
form2.ShowDialog();
}
}
????OK?????????????????????????????????????????????????????????????????1?????????????????????????????????100??????????????????????????????????Form2????Form2?????????????1????????д???????????????????????????????????????????
???????????????
???????????????????Σ???е???????????????鷳?????????????????????????????????????????ü?У??????????????????????????????????????????≈0??
????Form2:
//????Form2?????Form1
public partial classForm2 : Form1
{
publicint index;
public ListBox lb;
public Form2(string text)
{
//????й?????listBox??????????
this.listBox1.Visible=false;
InitializeComponent();
this.textBox1.Text = text;
}
private void btnChange_Click(object sender?? EventArgs e)
{
string text = this.textBox1.Text;
this.lb.Items.RemoveAt(index);
this.lb.Items.Insert(index??text);
this.Close();
}
}