Different behaviour of AdvColumnGrid GetEditorType Event

Upgrading from TMS v8.5.4.0 to 10.8.2.1.
While reviewing old code I noticed a behaviour change of column editor assignment.
Following code worked in the old version, but does not anymore in the VCL UI pack.
Empty combolist is shown in the grid, instead of a excepted A, B options.

procedure TForm1.AdvColumnGrid1GetEditorType(Sender: TObject; ACol,
  ARow: Integer; var AEditor: TEditorType);
begin
  AEditor:=edComboList;
  AdvColumnGrid1.ClearComboString;
  AdvColumnGrid1.AddComboString('A');
  AdvColumnGrid1.AddComboString('B');
  AdvColumnGrid1.Columns[ACol].ComboItems.Assign(AdvColumnGrid1.Combobox.Items);
end;

Used implementation is obviously not ideal (it is a part of a very old code in our application), I plan to reimplement it to more clean use, but still the behaviour is different, than was in the previous versions of the components.

The reason it was implemented this way was to have multiple combo boxes with multiple options dynamically assigned in runtime to the column grid.

Proper implementation that should work:

procedure TForm1.AdvColumnGrid1GetEditorType(Sender: TObject; ACol,
  ARow: Integer; var AEditor: TEditorType);
begin
  AEditor:=edComboList;
  AdvColumnGrid1.Columns[ACol].ComboItems.Clear;
  AdvColumnGrid1.Columns[ACol].ComboItems.Add('A');
  AdvColumnGrid1.Columns[ACol].ComboItems.Add('B');
end;

or

procedure TForm1.AdvColumnGrid1GetEditorType(Sender: TObject; ACol,
  ARow: Integer; var AEditor: TEditorType);
begin
  AEditor:=edComboList;
end;

procedure TForm1.AdvColumnGrid1GetEditorProp(Sender: TObject; ACol,
  ARow: Integer);
begin
  AdvColumnGrid1.ClearComboString;
  AdvColumnGrid1.AddComboString('A');
  AdvColumnGrid1.AddComboString('B');
end;

Thank you! The second implementation works, but the mentioned first one still displayed an empty combo for some reason.

Small change needed to make the first implementation work when you did not set Column.Editor at design-time:

procedure TForm1.AdvColumnGrid1GetEditorType(Sender: TObject; ACol,
  ARow: Integer; var AEditor: TEditorType);
begin
  AEditor := edComboList;
  AdvColumnGrid1.Columns[ACol].Editor := edComboList;
  AdvColumnGrid1.Columns[ACol].ComboItems.Clear;
  AdvColumnGrid1.Columns[ACol].ComboItems.Add('A');
  AdvColumnGrid1.Columns[ACol].ComboItems.Add('B');
  AdvColumnGrid1.Columns[ACol].ComboItems.Add('C');
end;

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.