急用,我实现在dbgrid中点击某行,从而弹出相应行的内容对应的数据填充的另外一个表单。同时,dbgrid是查询结果的显示,我不想限制其中必须有关键字字段,只要能得到用户点击字段或行的行数,我就能解决问题。无奈对dephi手生,请诸位帮忙搞定。谢谢!

解决方案 »

  1.   

    参考这个procedure TForm1.Button1Click(Sender: TObject);
    var
      i, j: Integer;
      s: string;
    begin
      if DBGrid1.SelectedRows.Count>0 then
        with DBGrid1.DataSource.DataSet do
          for i:=0 to DBGrid1.SelectedRows.Count-1 do
          begin
            GotoBook(pointer(DBGrid1.SelectedRows.Items[i]));
            for j := 0 to FieldCount-1 do
            begin          if (j>0) then s:=s+', ';
              s:=s+Fields[j].AsString;
            end;
            Listbox1.Items.Add(s);
            s:= '';
          end;
    end;