2011-10-19 44 views
7

我有一个TGrid与混合列(ImageColumn和StringColumn)。我可以使用onGetValue事件填充它,它可以正常工作。我的问题是:德尔福Firemonkey TGrid如何更新

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

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

回答

5

该网格只更新可见的单元格! 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; 

细胞不分配。

+0

感谢您的回复,完美的回答。 –

2

另一种选择是致电Grid1.beginUpdate;进行更改,然后致电Grid1.endupdate;这将导致可见网格重新计算和重绘。