我有一个混合列(ImageColumn 和 StringColumn)的 TGrid。我可以使用工作正常的 onGetValue 事件填充它。我的问题是:
如何强制整个网格重建并引发 onGetValue 事件?我目前正在使用 UpdateStyle。
如何更新网格中的单个单元格?
我有一个混合列(ImageColumn 和 StringColumn)的 TGrid。我可以使用工作正常的 onGetValue 事件填充它。我的问题是:
如何强制整个网格重建并引发 onGetValue 事件?我目前正在使用 UpdateStyle。
如何更新网格中的单个单元格?
网格只更新可见单元格!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;
当行永远不可见时,不分配单元格。
另一种选择是调用Grid1.beginUpdate;
进行更改,然后调用Grid1.endupdate;
这将导致可见网格重新计算和重绘。