簡體   English   中英

創建只讀文本列TGrid firemonkey

[英]Create readonly text column TGrid firemonkey

我從TColumn創建了自定義的Column類,並且正在像這樣在單元畫布上進行一些自定義繪制:

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;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM