Hello guys!
News from the front: Just found that the procedure doing this problem is
TZAbstractRODataset.MoveRecNo!
After a closer look into TZAbstractRODataset.Locate method, which calls MoveRecNo, I've found that the bug root are a bit different than I related:
Everytime, when TZAbstractRODataset find some row using locate, it fires a MoveRecNo to position the cursor over it.
Then, MoveRecNo uses the Resync procedure, which reset the cursor position. MoveRecNo uses a integer var to save this position and then re-set it when Resync is done.
The problem is: This procedure isn't enough to tell the TZAbstractRODataset that the cursor is postitioned over this row. When I scrolled down the DBGrid and the components tried to search for the next record (off the screen/scroll limit), it was taking the search result cursor, and not the current cursor (in this case, I scrolled by hand down the bottom of DBGrid).
Well, I solved it calling UpdateCursorPos by the end of MoveRecNo , right after re-setting the CurrentRow position.
Don't know if it's a good practice, but I'll wait for your comments!
Thanks!
UPDATE:
My version of the funcion MoveRecNo:
Code: Select all
procedure TZAbstractRODataset.MoveRecNo(Value: Integer);
var
PreviousCurrentRow: Integer;
begin
Value := Max(1, Value);
if Value < CurrentRow then
CheckBiDirectional;
if FetchRows(Value) then
CurrentRow := Value
else CurrentRow := CurrentRows.Count;
PreviousCurrentRow := CurrentRow;//Resync moves the current row away
try
if not (State in [dsInactive]) then Resync([]);
finally
CurrentRow := PreviousCurrentRow;
end;
UpdateCursorPos;
end;