Delphi Firemonkey TGrid how to update
Asked Answered
H

2

11

I have a TGrid with a mixture of columns (ImageColumn and StringColumn). I can populate it using onGetValue event which works fine. My questions are:

  1. How to force the entire grid to rebuild and cause onGetValue event? I'm using UpdateStyle at the monent.

  2. How can I update a single cell in the grid?

Hayse answered 19/10, 2011 at 13:6 Comment(0)
A
6

The grid updates only visible cells! Grid1.UpdateStyle force the grid to rebuild and is causing onGetValue events but its slow. Grid1.ReAlign is much faster.

As soon as cells become visible, they will be updated.

Updating 1 cell:

procedure TForm1.UpdateCell(col, row: integer);
var
  cell: TStyledControl;
begin
  cell := Grid1.Columns[col].CellControlByRow(row);
  if Assigned(cell) then
    cell.Data := 'Note: use the same datasource as OnGetValue';
end;

cell is not assigned when row never become visible.

Assembled answered 19/10, 2011 at 17:30 Comment(0)
P
6

The other option is to call Grid1.beginUpdate; make your changes and then call Grid1.endupdate; which will cause the visible grid to recalculate and redraw.

Papyrus answered 17/11, 2016 at 9:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.