Board index » delphi » Scrolling a TDBGrid without changing the selected record

Scrolling a TDBGrid without changing the selected record

I am using a TDBGrid through a slow ODBC connection to the data. When I
scroll the grid it changes the selected row and takes an age to update
all the "detail" queries run off it. The time it takes to update the
"detail" queries wouldn't be a problem if I could scroll the grid THEN
select a new row once the one I want was in view. Any ideas?

Regards

Adrian

 

Re:Scrolling a TDBGrid without changing the selected record


Adrian,

Couple of things you could try:

- Call DisableControls method on your grids in BeforeScroll and
EnableControls AfterControl (Have a look in the help)
- Disconnect the detail datasources until you have "settled" on a
record and then reconnect them

On Thu, 01 Jul 1999 16:52:14 -0300, Adrian Nash <adri...@gateway.bm>
wrote:

Quote
>I am using a TDBGrid through a slow ODBC connection to the data. When I
>scroll the grid it changes the selected row and takes an age to update
>all the "detail" queries run off it. The time it takes to update the
>"detail" queries wouldn't be a problem if I could scroll the grid THEN
>select a new row once the one I want was in view. Any ideas?

>Regards

>Adrian

--Donovan

Donovan J. Edye
Namadgi Systems
Web: www.namsys.com.au
E-Mail: dono...@namsys.com.au
Voice: +61 2 6285-3460
Fax: +61 2 6285-3459
TVisualBasic := Class(None);

Re:Scrolling a TDBGrid without changing the selected record


Don't use automatic linking, because it re-executes detail queries on every
datachange.

Instead, use manual linking with timer:
procedure Datasource1Datachange(...)
begin
  Timer1.Enabled := false;
  Timer1.Enabled := true;
end;

procedure Timer1Timer(..);
begin
  {details will be refreshed only when timer expires}
  DetailQ.Params[0].AsInteger := MasterQLinkField.AsInteger;
  DetailQ.Close;
  DetailQ.Open;
end;

I use timer interval from 300-500 ms.
With this small trick you'll see a real performance boost.

--
----------------------
Regards
Robert Cerny
Remove both qwe when replying
email: robert.qwe.ce...@neosys.xrs.qwe.si

No questions via email, unless explicitly invited.

Quote
Adrian Nash wrote in message <377BC6EE.E60F1...@gateway.bm>...
>I am using a TDBGrid through a slow ODBC connection to the data. When I
>scroll the grid it changes the selected row and takes an age to update
>all the "detail" queries run off it. The time it takes to update the
>"detail" queries wouldn't be a problem if I could scroll the grid THEN
>select a new row once the one I want was in view. Any ideas?

>Regards

>Adrian

Re:Scrolling a TDBGrid without changing the selected record


This works great, but you have to disable the timer at the end of the
Timer1Timer procedure!

Thanks Robert

Adrian

Quote
Robert Cerny wrote:
> Don't use automatic linking, because it re-executes detail queries on every
> datachange.

> Instead, use manual linking with timer:
> procedure Datasource1Datachange(...)
> begin
>   Timer1.Enabled := false;
>   Timer1.Enabled := true;
> end;

> procedure Timer1Timer(..);
> begin
>   {details will be refreshed only when timer expires}
>   DetailQ.Params[0].AsInteger := MasterQLinkField.AsInteger;
>   DetailQ.Close;
>   DetailQ.Open;
> end;

> I use timer interval from 300-500 ms.
> With this small trick you'll see a real performance boost.

> --
> ----------------------
> Regards
> Robert Cerny
> Remove both qwe when replying
> email: robert.qwe.ce...@neosys.xrs.qwe.si

> No questions via email, unless explicitly invited.
> Adrian Nash wrote in message <377BC6EE.E60F1...@gateway.bm>...
> >I am using a TDBGrid through a slow ODBC connection to the data. When I
> >scroll the grid it changes the selected row and takes an age to update
> >all the "detail" queries run off it. The time it takes to update the
> >"detail" queries wouldn't be a problem if I could scroll the grid THEN
> >select a new row once the one I want was in view. Any ideas?

> >Regards

> >Adrian

Other Threads