I need deselect some rows in TGrid by searched value in the columns, but cannot find any example for that. I'm using Delphi 10.3. The code below does not unselect the rows but quite the opposite. Can be "...SelectedRows.CurrentRowSelected := False" even used fot deselecting the row or should I use another approach?
This is what I tried so far:
class procedure TUnitEventHandler.TMenuItem_UnselectRowsWithValue_Click(Sender: TObject);
var
i : integer;
searchValue : string;
Grid : TrDBGrid_MS;
begin
Grid := GetGridFromSender(Sender);
searchValue := Grid.Fields[Grid.SelectedIndex].AsString;
Grid.DataSource.DataSet.DisableControls;
Grid.DataSource.DataSet.First;
for i := 0 to Grid.DataSource.DataSet.RecordCount-1 do
begin
if (searchValue = Grid.Fields[Grid.SelectedIndex].AsString) AND (Grid.SelectedRows.CurrentRowSelected) then
begin
Grid.SelectedRows.CurrentRowSelected := False;
end;
Grid.DataSource.DataSet.Next;
end;
Grid.DataSource.DataSet.EnableControls;
end;