procedure TForm1.Button1Click(Sender: TObject); var i, j: Integer; s: string; begin if DBGridEh1.SelectedRows.Count>0 then with DBGridEh1.DataSource.DataSet do for i:=0 to DBGrid1Eh.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; Listbox1.Items.Add(s); s:= ''; end; end;
书签可以记录你选过的记录: if DBGrideh1.SelectedRows.Count > 0 then begin sum := 0; with DBGrideh1.DataSource.DataSet do begin for i := 0 to DBGrid1.SelectedRows.Count-1 do begin GotoBook(Pointer(DBGrid1.SelectedRows.Items[i])); ... 取数据操作... end; end; end end;
以下是Ehlib中TDBGridEh.SelectedRows的帮助文件,TDBGridEh.SelectedRows Specifies a set of books for all the records in the dataset that correspond to rows selected in the grid.property SelectedRows: TBookListEh;DescriptionUse the properties and methods of the TBookListEh object returned by SelectedRows to • Determine the number of rows in the grid that are selected. • Determine whether the current record in the dataset is selected. • Determine whether a particular record in the dataset is selected. • Delete all selected rows from the dataset.SelectedRows is only meaningful when the Options property includes dgRowSelect. SelectedRows can only identify a single row unless the Options property includes dgMultiSelect.EhLib Software
var
i, j: Integer;
s: string;
begin
if DBGridEh1.SelectedRows.Count>0 then
with DBGridEh1.DataSource.DataSet do
for i:=0 to DBGrid1Eh.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;
Listbox1.Items.Add(s);
s:= '';
end;
end;
if DBGrideh1.SelectedRows.Count > 0 then
begin
sum := 0;
with DBGrideh1.DataSource.DataSet do
begin
for i := 0 to DBGrid1.SelectedRows.Count-1 do
begin
GotoBook(Pointer(DBGrid1.SelectedRows.Items[i]));
... 取数据操作...
end;
end;
end
end;
1 001 aaa bbb
2 002 aaa bbb
3 選中 選中 bbb
4 選中 選中 bbb
5 選中 選中 bbb
6 006 aaa bbb
Specifies a set of books for all the records in the dataset that correspond to rows selected in the grid.property SelectedRows: TBookListEh;DescriptionUse the properties and methods of the TBookListEh object returned by SelectedRows to • Determine the number of rows in the grid that are selected.
• Determine whether the current record in the dataset is selected.
• Determine whether a particular record in the dataset is selected.
• Delete all selected rows from the dataset.SelectedRows is only meaningful when the Options property includes dgRowSelect. SelectedRows can only identify a single row unless the Options property includes dgMultiSelect.EhLib Software