Custom grid in firemonkey

戏子无情 提交于 2021-02-11 07:07:11

问题


We are merging current vcl applications to Firemonkey. The current biggest issue is to create a tgrid with some custom columns.

I need a column with a combobox cells as well as a column with multiple check boxes in each cell.


回答1:


Take a look at my post http://monkeystyler.com/blog/entry/firemonkey-grid-basics-custom-cells-and-columns which explains the basics of FireMonkey grids and how to create custom columns.

And here's another post which uses generics to create a column for any component class http://monkeystyler.com/blog/entry/a-firemonkey-grid-column-for-any-control

Using the second method, create a component with your multiple check boxes and then create a column which uses it.




回答2:


Any solution that overrides the CreateCellControl method of the TColumn class does NOT work anymore. The new API provides an class called TGridModel, which through the OnCreateCustomEditor event allows you to dynamically create the editing components of a grid cell. However I still could not find any examples using this method.

procedure TForm1.MyOnCreateCustomEditor(Sender: TObject; const Column: TColumn; var Control: TStyledControl);
var
  idx: Integer;
begin
  idx := Column.Model.IndexOfColumn(Column);
  case idx of
    // Create controls here
  end;
end;

procedure TForm1.OnCreate(Sender: TObject);
begin
  inherited;
  Grid1.Model.OnCreateCustomEditor := MyOnCreateCustomEditor;
end;


来源:https://stackoverflow.com/questions/14338262/custom-grid-in-firemonkey

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