How to populate a user-defined column in an FMX TGrid by LiveBindings

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 16:20:14

问题


I am trying to create a TCalendarEdit containing column inside a grid component in the following way.

type
  TDatecell = class(TCalendarEdit)
  end;

  TDateColumn = class(TColumn)
  private
    function CreateCellControl: TStyledControl; override;
  public
    constructor Create(AOwner: TComponent); override;
  end;
...
constructor TDateColumn.Create(AOwner: TComponent);
begin
  inherited;
end;

function TDateColumn.CreateCellControl: TStyledControl;
begin
  Result := TDatecell.Create(Self);
end;

It works fine. Then I am stack at populating the column from a FDQuery field of date type. I am capable to establish a Live Binding link and populate the columns of traditional types as well as I can add my DateColumn to the grid. I tried to connect this column to BindSourceDB by

LinkGridToDataSourceBindSourceDB1.Columns.Add;
LinkGridToDataSourceBindSourceDB1.Columns.Items
[LinkGridToDataSourceBindSourceDB1.Columns.Count-1].
MemberName:='date_set_by_user';

but this destroys all the columns in the grid and creates a new one (I suppose of TColumnType). The event OnGetValue of the grid traditionally used to assign values to cells in user declared columns does not fire if there is a LiveBinding link. I think it is possible to to fill the columns manually, but how can I populate this column with Livebindings mechanism?

来源:https://stackoverflow.com/questions/32258525/how-to-populate-a-user-defined-column-in-an-fmx-tgrid-by-livebindings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!