0

Using Delphi XE2.

I have a tcxgrid which is connected to a datasource, which is looking at a table in a database, the cxgrid is displaying fields and records from within that table.

Does anyone know how to Refresh the tcxgrid without losing the current row selected?

Thanks,

Ken White
  • 123,280
  • 14
  • 225
  • 444
Sharpie
  • 373
  • 2
  • 15
  • 34

1 Answers1

0

To restore the selection you can use cxStatusKeeper (it's a public unit that you can download from the support center of DevExpress):

{Init the component for restore selection}
FGridStatus := TcxGridDBTableKeeper.Create(self);
FGridStatus.LoadExpanding   := False;
FGridStatus.LoadSelection   := True;
FGridStatus.LoadFocus       := True;
FGridStatus.LoadTopRecord   := False;
FGridStatus.LoadWithDetails := False;
FGridStatus.LoadFocusedView := True;
FGridStatus.LoadFocusedItem := True;
FGridStatus.View            := gvTableElementi;

{save the current items} 
FGridStatus.Store;

{restore the selection}   
if FGridStatus.GridStored then
  FGridStatus.Restore;
Obsidian Age
  • 41,205
  • 10
  • 48
  • 71