2015-08-20 43 views
0

我創建從TColumn我的自定義列類和我做對細胞帆布一些自定義繪製這樣的:創建只讀文本列TGrid firemonkey

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

的問題是,我的細胞都在默認情況下編輯,如果我不設置網格選項中的編輯模式,他們將不可編輯,但我只想要某些單元格是不可編輯的。

回答

0

你可以覆蓋保護TCustomGrid.CanEdit功能在你的單位,TForm的/ TFRAME的聲明之前:

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;