我的GRID Options 设置为Selecterow = True, 多行选择也设置为True,如何将选定的几行数据添加到另外一个数据表中?

解决方案 »

  1.   

    用一个字符型数据,
    可以将要复制的数据记录号记录下来!再用SQL语句进行,添加到另一个数据表中!我想这个SQL语句就不用说了,关键是中间的条件:
    var
    str:string;
    I:integer;
    begin
    str:='...';     //取得要复制的记录号
    ....
    I:=0;
    repeat
    begin 
    Rect=strtoint(copy(str,I,1));
    I:=I+1;
    end;
    until Rect.leve;
    ...........
    end;
      

  2.   

    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;
      

  3.   

    也可以你把选择的数据表的主键记录到一个tstringlist变量中
    然后在根据主键在数据库查询出结果 插入到另外一个dbgrid中
      

  4.   

    lmjzw(电脑世界) 的没看懂?
      

  5.   

    angle097113(深思)的好像可行,赶紧是一下。