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;
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;
if DBGrid1.SelectedRows.CurrentRowSelected then
ListBox1.items.add(DMsea1.Qche.Fields[0].asstring);
DMsea1.Qche.Next;
end;
Opitons->dgMultiSelect->True
First;
while not Eof do begin
SelectedRows.CurrentRowSelected := True;
Next;
end;
end;
procedure TCLCK_KCJZ_Form.b_SelectAllClick(Sender: TObject);
var
i:integer;
begin
if tmxzjbb.Active then
begin
tmxzjbb.First;
i := 0;
while not tmxzjbb.Eof do
begin
dbg_mxzlb.SelectedRows.CurrentRowSelected := true;
tmxzjbb.Next;
i := i + 1;
end;
end;
end;
就能选定该行。
提取时:with DBGrid1 do
begin
For i:=0 to SelectedRows.Count do
begin
DataSource.DataSet.GotoBook(SelectedRows.Items[i]);
....
end;
end;
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 i := 0 to FieldCount-1 do
begin
s:=Fields[i].AsString;//提取记录
end;
end;