先谢,问题明确下,就是当我双击DBGrid1中的一列数据后,在DBGrid2中会显示出这列数据,如何实现?DBGrid1.DbClick事件要怎么写,

解决方案 »

  1.   

    dbgrid1 帮定的dataset1
    dbgrid2 帮定的dataset2dbgrid1 onclick事件
    dataset2.close;
    dataset2.commandtext:='selct * from tables where xx='+quotedstr(dataset1.fieldbyname('xx').asstring);
    dataset2.open;
      

  2.   

    DbGrid1接DataSet1
    DataSet1中的SQL语句为
    Select * from Table
    where 1=1DbGrid接DataSet2
    DataSet2中的SQL语句为
    Select * from table
    where 1=0然后
    DbGrid1中双击的时候
    Begin
      DataSet1.FieldByName('主键或唯一标志').value;
      然后
      DataSet2.Close;
      DataSet2.Sql[1] := 'where 主键或唯一标记 = '上面的DataSet1.FieldByName('主键或唯一标志').value;
      DataSet2.Open;
    end;
      

  3.   


    其实楼上两位的方法都差不多的 关键是这一句: DataSet2.Sql[1] := 'where 主键或唯一标记 = '上面的DataSet1.FieldByName('主键或唯一标志').value; 
      

  4.   

    dbgrid1 onclick事件
    dataset2.close;
    dataset2.commandtext:='selct * from tables where xx='+quotedstr(dataset1.fieldbyname('xx').asstring);
    dataset2.open;