How to populate Combobox before its openning?


I wish to have an easy way to change the available items of an existing ComboBox each time
the user opens it… Maybe using some kind of on BeforeOpen event…
Any clue ? Thanks in advance


Maybe derive your own class from ComboBox, and override showPopup()? The comments there suggest that is an option.

1 Like

Thx but not that easy : inside the DerivedComboBox showPopup event how to easy access main the main form ?

There are several options. If the “main form” is the parent of your combo box, then I think you can just call getParentComponent() to get access to it. If your parent component is also a custom class (derived from Component), then you can use dynamic_cast on the return value from getParentComponent()), to cast it to the parent class type, and use the resulting pointer to call functions in your parent class. Or, you can pass a pointer to the parent class in the constructor for your DerivedComboBox, store that pointer as a member, and use that pointer whenever you need to access the parent.