Hi!
I know how to select single row/record or to select multiple rows in series, but how to select some rows like in all windows grids. For example, with using shift and ctrl keys selecting rows 1..4, then additionaly rows 6,7 without row 5 like in TDBGrid.
I wrote class helper function that returns record ID's for selected rows in grid:
function TITDBAdvGrid.ExportSelectedToCsv( const aFieldName: String ): String;
var
br, ukupno: integer;
row, coll: integer;
List: TStringList;
begin
List := TStringList.Create;
List.Delimiter := ',';
try
try
coll := Self.ColumnByFieldName[ aFieldName ].Index;
if coll > -1 then
for br := 0 to Self.SelectedRowCount - 1 do
begin
row := Self.SelectedRow[ br ];
List.Add( Self.Cells[ coll, row ] );
end;
except
Result := '';
end;
finally
result := List.DelimitedText;
List.Free;
end;
end;
Grid options nas selected RangeSelected, but this enables only range select, not custom row selecting like in TDBGrid.
Sugestion or Idea?
Thanks!
Did you have a look at the demo ADOSelection in the TDBAdvGrid samples distribution that shows such possible implementation?
Yes, I considered solution with calculated boolean field but this isn't practical as usualy used range selecting with selection adding, removing and inverting with click + shift/ctrl keys.
At last, I must use checkboxes but I prefer specified method with click + keys.
Another sugestion maybe?
An alternative could be to set grid.PageMode= false and use the disjunct row selection mode (grid.MouseActions.DisjunctRowSelect = true)
Thanks!