1. After the refresh, will automatically jump to the middle, although the selected or the line, but this let the customer feel that data in the jump)
2. This problem does exist, we used to have that somebody had solution seems to be calculating the position of the current record in the DBGridEh, then move the data table, make it like the original, but the efficiency is too low, no use, is ultimately did customer work (it does not affect use)
==========================================================================
Solve adoquery1. Refresh in the case of large amount of data is very slow, and each time to refresh memory have been rising,
Using ADOQuery1 Requery refresh very fast, do not take a memory, but there is a problem with this approach is unable to locate to the current cursor position, customer experience is very bad,
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
The following code can be perfect to solve these problems, (because I see there are a lot of people are troubled by the question, all share to everyone, hope everybody can improve better and faster solution!)
Procedure ssdcwt_ADOQuery ();
Var
Ss_RecNo ss_Row, ss_RowCount ss_i: Integer;
The begin
If Form1. ADOQuery1. Active then
The begin
Try
Ss_RecNo:=Form1. ADOQuery1. RecNo - 1;
Ss_RowCount:=Form1. DBGridEh1. RowCount - 1;
Ss_Row:=Form1 DBGridEh1. Row;
Ss_i:=ss_RowCount - ss_Row;
Form1. ADOQuery1. DisableControls;
Form1. ADOQuery1. Requery;
Form1. DBGridEh1. MoveBy (ss_RecNo + ss_i);
Form1. DBGridEh1. MoveBy (- ss_i);
Form1. ADOQuery1. EnableControls;
Except,
Form1. ADOQuery1. EnableControls;
Form1. RichEdit1. Lines. Insert (0, 'go wrong! Time: '+ timeToStr (time));
Form1. ADOQuery1. Close;
Form1. ADOQuery1. SQL. Text:='select * from aaa';
Form1. ADOQuery1. Open;
Form1. ADOQuery1. Sort:='LimitOrders_1';//this is sorting, if you write in SQL directly open the sorting, DBGridEh then you click on the title sorting will go wrong,
end;
End
The else
The begin
Form1. RichEdit1. Lines. The Add (' Form1 ADOQuery1 not activated! Time: '+ timeToStr (time));
Form1. ADOQuery1. Close;
Form1. ADOQuery1. SQL. Text:='select * from aaa';
Form1. ADOQuery1. Open;
end;
end;