Frequently Asked Component Specific Questions

Options

Display all FAQ items

Search FAQ items:


Displaying items 1 to 1 of 1, page 1 of 1

<< previous next >>

TMS FMX UI Pack
TTMSFMXGrid: How to have multiple columns with etComboBox type

To have several columns in the combobox, you need to fill the CellComboBox through an event, that is triggered before the combobox is shown.

Sample code:
procedure TForm1.FormCreate(Sender: TObject);
begin
  TMSFMXGrid1.DefaultColumnWidth := 100;
end;

procedure TForm1.TMSFMXGrid1CellEditGetData(Sender: TObject; ACol,
  ARow: Integer; CellEditor: TFmxObject; var CellString: string);
begin
  if CellEditor is TComboBox then
  begin
    (CellEditor as TComboBox).Items.Clear;
    (CellEditor as TComboBox).Items.Add(''Item 1 for '' + IntToStr(ACol) + '':'' + IntToStr(ARow));
    (CellEditor as TComboBox).Items.Add(''Item 2 for '' + IntToStr(ACol) + '':'' + IntToStr(ARow));
    (CellEditor as TComboBox).Items.Add(''Item 3 for '' + IntToStr(ACol) + '':'' + IntToStr(ARow));
  end;
end;

procedure TForm1.TMSFMXGrid1GetCellEditorType(Sender: TObject; ACol,
  ARow: Integer; var CellEditorType: TTMSFMXGridEditorType);
begin
  CellEditorType := etComboBox;
end;