procedure TDOC_BILL.DataGridClick(Sender: TObject);
var
i, j: Integer;
begin
if DataGrid.SelectedCount > 0 then
with DataGrid.DataSource.DataSet do
for i := 0 to DataGrid.SelectedCount - 1 do
begin
if DataGrid.Items.Selected then
begin
j := j + FieldByName('F_JS').AsInteger;
edit1.Text := IntToStr(j);
end;
end;
直接从DataGrid中取数据试下
nSum := 0;
for i := 0 to DataGrid.Count - 1 do
if DataGrid.Items.Selected then
begin
nSum := nSum + DataGrid.ColumnDefs[2].Field.AsInteger;
end;
13楼的代码的确有问题。 还是用10楼的代码吧
nSum := 0;
if DataGrid.SelectedCount > 0 then
with DataGrid.DataSource.DataSet do
for i := 0 to DataGrid.SelectedCount - 1 do
begin
Bookmark := DataGrid.SelectedRows;
nSum := nSum + Fields[2].AsInteger;
end;