好像只有SELECTEDROW.COUNT这样的属性,不知道怎么逐条获取数据

解决方案 »

  1.   

    Set DBGrid Option dgMultiSelect to true and put next code to the button handler: 
    procedure TForm1.Button1Click(Sender: TObject);
    var
      X: Word;
      TempBook: TBookMark;
    begin
      with DBGrid1.DataSource.DataSet do
      begin
        DisableControls;
        with DBGrid1.SelectedRows do
          if Count<>0 then
          begin
            TempBook:=GetBook;
            for X:=0 to Count-1 do
            begin
              if IndexOf(Items[X])>-1 then
              begin
                Book:=Items[X];
                ShowMessage(Fields[1].AsString);
              end;
            end;
          end;
        GotoBook(TempBook);
        FreeBook(TempBook);
        EnableControls;
      end;
    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.   

    //&#187;&#241;&#200;&#161;DBGridEh1&#214;&#208;&#181;&#196;&#209;&#161;&#214;&#208;&#202;&#253;&#190;&#221;&#208;&#208;
        with DBGridEh1.DataSource.DataSet do
            for i:=0 to DBGridEh1.SelectedRows.Count-1 do begin
                GotoBook(pointer(DBGridEh1.SelectedRows.Items[i]));
            for j := 0 to FieldCount-1 do begin
                if (j>0) then s:=s+'-- ';
                s:=s+Fields[j].AsString;
            end;
    //&#197;&#208;&#182;&#207;&#188;&#199;&#194;&#188;&#214;&#216;&#184;&#180;
            if listbox1.Items.IndexOf(s)<0 then
            begin
                Listbox1.Items.Add(s);
                s:='';
            end
             else
            begin
                MessageDlg('&#196;ú&#210;&#209;&#204;í&#188;&#211;&#193;&#203;"'+trim(s)+'" &#213;&#226;&#204;&#245;&#188;&#199;&#194;&#188;!',mtInformation,[mbok],0);
                s:= '';
             end;
             end;
    一定行