DBAdvGrid RowHeights - 更改除 1 以外的所有行

DBAdvGrid RowHeights - alter all rows except 1

我在 DBAdvGrid(TMS) 的 CustomCellDraw 事件 中使用以下代码来增加行高。

procedure TForm1.DBAdvGrid1CustomCellDraw(Sender: TObject; Canvas: TCanvas;
  ACol, ARow: Integer; AState: TGridDrawState; ARect: TRect; Printing: Boolean);
begin
DBAdvGrid1.RowHeights[ARow]:=120;
end;

如何避免增加第 0 行,这是网格中的第 1 行,包含第 names/headers 列? - 我希望该行保持不变,而其余所有行都应通过上述代码调整大小。基本上它应该忽略行索引 0 并从行索引 1

开始

会是这样的:

procedure TForm1.DBAdvGrid1CustomCellDraw(Sender: TObject; Canvas: TCanvas; 
  ACol, ARow: Integer; AState: TGridDrawState; ARect: TRect; Printing: Boolean);
begin
  if ARow > 0 then
    DBAdvGrid1.RowHeights[ARow] := 120;
end;

但不要通过绘图事件修改行高。该事件触发频繁,专门用于内容绘制,不用于调整内容大小。更糟糕的是,如果你允许行大小并且用户会尝试设置行高,它会反过来触发该事件,您将在其中更改高度,因此您会与用户发生冲突。

内容大小调整应尽早完成,如 OnCustomCellSize 事件中所示 this example

但为了您的目标,我认为无需额外代码即可设置 DefaultRowHeightFixedRowHeight 属性。