begin
if dbgrid1.SelectedRows.Curre
begin
ShowMessage('This Record was selected');
dbgrid1.SelectedRows.Curre
end
else
begin
ShowMessage('This Record was not selected');
dbgrid1.SelectedRows.Curre
end;
end;
procedure TForm1.Button4Click(Sender
var I : Integer;
begin
for i := 0 to dbgrid1.SelectedRows.Count
begin
dbgrid1.DataSource.Dataset
//Do Something
ShowMessage(dbgrid1.DataSo
end;
end;
برای انتخاب چندین رکورد از کد زیر میشود استفاده کرد
با ید انتخاب ردیف و انتخاب چندین ردیف فعال باشد
DBGrid1.Options:=DBGrid1.Options + [dgMultiSelect,dgRowSelect]
if (Shift = []) then
begin
case Key of
VK_UP: begin
Key := 0;
TDBGrid(Sender).DataSource.DataSet.Prior;
end;
VK_Down: begin
Key := 0;
TDBGrid(Sender).DataSource.DataSet.Next;
end;
VK_Space: begin
Key := 0;
TDBGrid(Sender).SelectedRows.CurrentRowSelected :=
NOT(TDBGrid(Sender).SelectedRows.CurrentRowSelected);
end;
end;
end;