创建只读文本列TGrid firemonkey

时间:2015-08-20 03:11:21

标签: delphi firemonkey

我从TColumn创建了自定义列类,我在单元格画布上做了一些自定义绘图,如下所示:

type
  TCustomCol = class(TColumn)
  protected
    procedure DrawCell(const Canvas: TCanvas; const Row: integer; const Bounds: TRectF; const Value: TValue); override;
  end;

问题是默认情况下我的单元格都是可编辑的,如果我不在网格选项中设置编辑模式,它们将是不可编辑的,但我只希望某些单元格不可编辑。

1 个答案:

答案 0 :(得分:0)

在声明TForm / TFrame之前,您可以覆盖设备中受保护的TCustomGrid.CanEdit功能:

type
  TGrid = class(FMX.Grid.TGrid)
  protected
    function CanEdit: Boolean; override;
  end;

  TmyForm = class(TForm)
    myGrid: TGrid;
  .....
  end;
implementation
....
function TGrid.CanEdit: Boolean;
begin
  Result := inherited CanEdit and not ((ColumnIndex = 0) and (Selected < 2)); //use your condition
end;