With TColComboInspectorEditLink, define DropWidth at runtime

Hi,

I'm using a tInspectorBar with a TColComboInspectorEditLink. I load the information for the TColComboInspectorEditLink in the OnSetProperties event, and while I'm at it, I calculate the column widths and the combo's DropWidth.
However, when the combo opens, the widths are those of the previous item, not the current one.

In the equivalent scenario with tAdvStringGrid, we use GetEditorType to load the combo and GetEditorProp to modify its display.

Which event should I use in tInspectorBar? I’ve tried OnItemOpen and OnEditProp, but without success.

Regards

I cannot see a problem when setting properties for TColumnComboBox from the TInspectorBar.OnEditProp event, like can be seen in this exampe:

Hi thanks for the quick answer.

The pb is not the size of each column, but the final size of the combo indicates with DropWith.

The actual dropWith is set from the previous item.

Project1.zip (77.6 KB)

I include a project.

I do not understand what you try to do and how you interpret that something is wrong.
The DropWidth in your code is set only once and it is always set to the same value DropWidth := 200
And I see the DropWidth as such is always, as expected 200.
If I change this value

If I add the code:

               if Tag = 0 then
                begin
                  DropWidth := 400;
                  Tag := 1;
                end
                else
                begin
                  DropWidth := 200;
                  Tag := 0;
                end;

I see it toggle as expected, so it is unclear to me what you mean that would not be working correct?

I'm afraid I send you a wrong project :man_facepalming: , sorry

This the right one ,

Project1.zip (8,2 Ko)

Change your code to:

var
  w: integer;
begin
  combo_Accessoire.ColumnComboBox.Columns.clear;
  combo_Accessoire.ColumnComboBox.Columns.Add;
  combo_Accessoire.ColumnComboBox.Columns.Add;

  combo_Accessoire.ColumnComboBox.ComboItems.clear;
  combo_Accessoire.ColumnComboBox.ComboItems.add;
  combo_Accessoire.ColumnComboBox.ComboItems[0].Strings.add('1');
  combo_Accessoire.ColumnComboBox.ComboItems[0].Strings.add('Item A');
  combo_Accessoire.ColumnComboBox.ComboItems.add;
  combo_Accessoire.ColumnComboBox.ComboItems[1].Strings.add('2');
  combo_Accessoire.ColumnComboBox.ComboItems[1].Strings.add('Item B');
  combo_Accessoire.ColumnComboBox.ComboItems.add;
  combo_Accessoire.ColumnComboBox.ComboItems[2].Strings.add('3');
  combo_Accessoire.ColumnComboBox.ComboItems[2].Strings.add('Item C');

  CASE Item.Tag OF
     1 : begin
           combo_Accessoire.ColumnComboBox.Columns[0].Width := 30;
           combo_Accessoire.ColumnComboBox.Columns[1].Width := 500;
         end;
     2 : begin
           combo_Accessoire.ColumnComboBox.Columns[0].Width := 200;
           combo_Accessoire.ColumnComboBox.Columns[1].Width := 1000;
         end;
   END;   //  Fin de CASE

   w := combo_Accessoire.ColumnComboBox.Columns[0].Width + combo_Accessoire.ColumnComboBox.Columns[1].Width;
   combo_Accessoire.ColumnComboBox.DropWidth :=  w;
end;

Thanks

Not trivial, by the way ;)