问题
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