先将form1中的grid清空:public void getDataFromAddress(ArrayList al) 
        { 
            dataGridView2.Rows.Clear();
            for (int i = 0; i < al.Count; i++) 
            { 
                string[] data = al[i].ToString().Split(';'); 
                dataGridView2.Rows.Add(); 
                dataGridView2.Rows[i].Cells[0].Value = true; 
                dataGridView2.Rows[i].Cells[1].Value = data[0]; 
                dataGridView2.Rows[i].Cells[2].Value = data[1]; 
              
            } 
        } 

解决方案 »

  1.   

    你的代码不能实现你说的功能吧。“我Form2的datagridview有3行数据,当我选择其中2行数据添加到Form1中的datagridview是,数据能够显示出来。当我再从Form2中选择一行数据,添加到Form1时,Form1出现了3行数据,其中有一行是空白的。 ”Form2 for 循环里没有判断行是否选中,数据全读了。给Form1赋值后al没有清空。
      

  2.   

    将ArrayList al = new ArrayList(32)放到button1_Click中去或者this.Close()之前将al清空。
      

  3.   

    回楼主! 你的datagridview每设置好! 点击datagridview的右上角的小三角那里。下拉菜单中 有个添加项!把那个取消选中就可以了
      

  4.   

    Form2中的代码   有问题应该判断选中的数据    然后再添加到Form1中