Hi forum,
I have a little problem with positioning in DBGrid after update of records.
First of all, this is a dataset where several users are working on at the same time. They might update records, but never delete or add.
I use a customized version of the sample code I have found on
this works fine when the active record > middle record. But when active record< middle record the correct record is highlighted, but it changes position to the middle of the dbgrid. Is there a way to get the dbgrid NOT to change the position for the active record to the middle if position is above the middle?
I have a little problem with positioning in DBGrid after update of records.
First of all, this is a dataset where several users are working on at the same time. They might update records, but never delete or add.
I use a customized version of the sample code I have found on
Code:
THackDBGrid = class(TDBGrid)
procedure...
rowDelta := -1 + THackDBGrid(DBGrid1).Row;
with AdoQuery1 do
begin
row := RecNo;
<I close, open an requery AdoQuery1 to check if someone else has done something to the records>
DisableControls;
RecNo := row;
MoveBy(-rowDelta) ;
MoveBy(rowDelta) ;
EnableControls;
<I do the update I want to do to the record, post, close, open and requery>
DisableControls;
RecNo := row;
MoveBy(-rowDelta) ;
MoveBy(rowDelta) ;
EnableControls;
end;