假设Form1中有DataGrid1,显示:
   
    学校名称      班级
     学校1         1
     学校1         2
     学校1         3
     学校2         1
     学校2         2
     ……         ……    希望选择了DataGrid1的某一行(假设为上面的第三行)后,双击DataGrid1,打开新窗口Form2,Form2中有DataGrid2,显示:    班级         学生       性别
     3            甲         男
     3            乙         女
    ……    如何写代码将所选择的行的参数带入Form2 ?    我很菜,希望能得到具体一些的指点。

解决方案 »

  1.   

    这个很简单的,在FORM2中这样写:
    private string xx="";
    public string xx_value
    {
      get{return xx;}
      set{xx=value;}
    }
    这样在new 出FORM2的时候设置xx_value的值,然后在FORM2中取出XX的值就可以了,这样值就传好了!
      

  2.   


    谢谢趴趴熊,但是我还想知道怎样取出DataGrid1中班级的编号假设数据库中有三张表,学校表School  字段有:school_id,  school_name班级表Class   字段有:class_id,   school_id,   class_name学生表Student  字段有:student_id, class_id,  student_name, student_sexDataGrid1中显示的是School.school_name和Class.class_name  用的数据源是DataView,我选定一行以后如何在双击事件中取得选定行的class_id ?
      

  3.   


    有没有人知道怎样取出没有显示在DataGrid的那一个class_id字段呀?
      

  4.   

    在生成DataGrid1的 取三个字段
    至于第三个字段class_id ,你可以添加一个 DataGridTextBoxColumn() 
    把这个列的 width 设为 0然后, 通过 DataGrid1[DataGrid1.CurrentRowIndex, 0]
               DataGrid1[DataGrid1.CurrentRowIndex, 1]
               DataGrid1[DataGrid1.CurrentRowIndex, 2]的值,把 这些内容 传给 DataGrid2 的某些属性...
    然后再进行其他操作..