Page 1 of 1

TCRDBGrid selected line display after TitleClick

Posted: Mon 28 Nov 2011 11:16
by Adonis
Hello,
We have Delphi XE 2 with Odac 8.0.2.
We have a TCRDBGrid in a Dialog form used to display a list.
We have 4 columns in this grid.
We can sort the columns with a click on the title.
We have properties dgRowLines, dgRowSelect set to true.
when we click in the grid, we have an entire row selected.
When we sort with a click on a column, the blue line (selection) is moved to the bottom of the list, with the row.

Is it possible to keep the first line blue when we sort the lists ?
(keep the 1st line selected after a sort ?)

Thanks

Posted: Mon 28 Nov 2011 12:44
by AlexP
Hello,

For the cursor to stay on the first line after performing sorting in TCRDBGrid, you can use the CRDBGrid.OnTitleClick event in which you can call the First method:


procedure TForm1.CRDBGrid1TitleClick(Column: TColumn);
begin
OraQuery1.First;
end;

But the existing behaviour is more correct, because the cursor always stays on the selected record.

Posted: Mon 28 Nov 2011 15:10
by Adonis
Thanks Alex P, it works well !!

It was a request of a customer, that's why we needed this behaviour !