【问题标题】:Create readonly text column TGrid firemonkey创建只读文本列 TGrid firemonkey
【发布时间】:2015-08-20 03:11:20
【问题描述】:

我从 TColumn 创建了我的自定义 Column 类,并且我正在像这样在单元格画布上进行一些自定义绘图:

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

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

【问题讨论】:

    标签: delphi firemonkey


    【解决方案1】:

    在声明 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;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-10
      • 2020-11-20
      • 1970-01-01
      • 2013-03-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多