How to update dbgrid without closed and open dataset in delphi?

I need to constantly update dbgrid, in real time. Close and open the dataset is working fine, but dbgrid is blinking. What can I do to avoid this?

I need a solution like Ajax that updates only the necessary ones.

thanks

+7
ajax delphi dataset dbgrid
source share
3 answers

Have you tried using Disable- and EnableControls ?

DataSet.DisableControls; try DataSet.Close; DataSet.Open; finally DataSet.EnableControls; end; 

In addition, it should be possible to simply call DataSet.Refresh instead of closing and opening to get the same result.

+14
source share

I use this in my application

 DataSet.MergeChangeLog; DataSet.ApplyUpdates(-1); DataSet.Refresh; 

The above code is in action named actRefreshData strong>, in ActionManager

When I need to use, I'll just call him

 actRefreshData.Execute; 

Hope this helps.

Hint: you can add a Timer and automate this

0
source share

Look at here:

 type THackDataSet=class(TDataSet); // a nice "hack" so we can access //protected members THackDBGrid=class(TDBGrid); procedure {tdmdb.}refreshgrid(grid : tdbgrid); var row, recno : integer; ds : tdataset; b : tbookmark; begin Row := THackDBGrid(grid).Row;// or THackDataSet(ds).ActiveRecord ds := grid.datasource.dataset; RecNo := ds.RecNo; b := ds.GetBookmark; try ds.close; ds.Open; finally if (b<>nil) and ds.BookMarkValid(b) then try // ds.GotoBookMark(b); ds.CheckBrowseMode; THackDataSet(ds).DoBeforeScroll; THackDataSet(ds).InternalGotoBookmark(b); if THackDataSet(ds).ActiveRecord <> Row - 1 then THackDataSet(ds).MoveBy(Row - THackDataSet(ds).ActiveRecord - 1); ds.Resync([rmExact{, rmCenter}]); THackDataSet(ds).DoAfterScroll; finally ds.FreeBookMark(b); end else if (recno<ds.RecordCount) and (recno<>ds.RecNo) then begin ds.First; ds.MoveBy(Max(0, recno-1)); end; end; end; 
0
source share

All Articles