Delphi Firemonkey TGrid如何更新

Ala*_*ace 9 delphi tgrid firemonkey

我有一个混合列的TGrid(ImageColumn和StringColumn).我可以使用onGetValue事件填充它,它可以正常工作.我的问题是:

  1. 如何强制整个网格重建并导致onGetValue事件?我正在使用UpdateStyle.

  2. 如何更新网格中的单个单元格?

Arj*_*pek 6

网格仅更新可见单元格!Grid1.UpdateStyle强制网格重建并导致onGetValue事件但速度很慢.Grid1.ReAlign要快得多.

一旦细胞变得可见,它们就会被更新.

更新1个单元格:

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;
Run Code Online (Sandbox Code Playgroud)

当行永远不可见时,不会分配单元格.


ska*_*adt 6

另一种选择是调用Grid1.beginUpdate;make your changes 然后调用Grid1.endupdate;这将导致可见网格重新计算和重绘。