form2中添加一个属性,用于保存修改后的结果。
form1中取这个属性的值,更改SelectedItems中的项。

解决方案 »

  1.   

    能不能说的具体点,我的代码是这样的。Form1中:
    private void button1_Click(object sender, EventArgs e)
            {
                        string ex1 = listView1.CheckedItems[0].Text;
                        string ex2 = listView1.CheckedItems[0].SubItems[1].Text;
                        string ex3 = listView1.CheckedItems[0].SubItems[2].Text;
                        Form2 frmEdit = new Form2(ex1,ex2,ex3);
                        frmEdit.ShowDialog(this);
             }
    Form2中:
    private void button1_Click(object sender, EventArgs e)
            {
                    string strconnection1 = "Integrated Security = SSPI;Database = users;Server = (local)";
                    SqlConnection connection1 = new SqlConnection(strconnection1);
                    connection1.Open();
                    SqlCommand cmd1 = connection1.CreateCommand();
                    cmd1.CommandText = "INSERT INTO [Usermanagement] VALUES ('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "');
                    cmd1.Connection = connection1;
                    cmd1.CommandType = CommandType.Text;
                    int n = cmd1.ExecuteNonQuery();
                    connection1.Close();
                    this.Close();//关闭Form11 
             }
    返回frmEdit.ShowDialog(this)的时候,数据库已经更新,但是listview里选中的checkbox那一项并没有更新……
      

  2.   

    //在form1中
     private void button1_Click(object sender, EventArgs e)
            {
                Form2 frm = new Form2();
                frm.form1 = this;
                frm.Show();
            }
    //form2中
    public Form1 form1;
    private void button1_Click(object sender, EventArgs e)
    {
        form1.listView1.Items.Add(....);
    }
    http://topic.csdn.net/u/20100106/20/e9697297-75f9-4450-aaa9-da0da416cf41.html
      

  3.   


    public class Form2:Form
    {
        ....   public string Text1
       {//定义一个只读属性,返回textBox1的Text属性值,其他的TextBox可类似定义
         get
            {
               return textBox1.Text;
             }
        }
     }public class Form1:Form
    {
      ..
      private void button1_Click(object sender, EventArgs e)
      {
      string ex1 = listView1.CheckedItems[0].Text;
      string ex2 = listView1.CheckedItems[0].SubItems[1].Text;
      string ex3 = listView1.CheckedItems[0].SubItems[2].Text;
      Form2 frmEdit = new Form2(ex1,ex2,ex3);
      frmEdit.ShowDialog(this);
      listView1.CheckItems[0].Text=frmEdit.Text1;//取Form2中定义的属性
       ...
      }