创建只读文本列 TGrid firemonkey
Create readonly text column TGrid firemonkey
我从 TColumn 创建了我的自定义列 类,我正在单元格 canvas 上做一些自定义绘图,如下所示:
type
TCustomCol = class(TColumn)
protected
procedure DrawCell(const Canvas: TCanvas; const Row: integer; const Bounds: TRectF; const Value: TValue); override;
end;
问题是我的单元格默认都是可编辑的,如果我不在网格选项中设置编辑模式,它们将不可编辑,但我只希望某些单元格不可编辑。
在声明 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;
我从 TColumn 创建了我的自定义列 类,我正在单元格 canvas 上做一些自定义绘图,如下所示:
type
TCustomCol = class(TColumn)
protected
procedure DrawCell(const Canvas: TCanvas; const Row: integer; const Bounds: TRectF; const Value: TValue); override;
end;
问题是我的单元格默认都是可编辑的,如果我不在网格选项中设置编辑模式,它们将不可编辑,但我只希望某些单元格不可编辑。
在声明 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;