Search code examples
firemonkeyc++builder

How do I access the ListBox of a TComboEdit in FireMonkey?


I can easily access the ListBox of a TComboBox to change its style properties in the OnEnter event, like this:

combo_box->ListBox->StylesData["shadow.Softness"] = TValue::From<float>(0.3 * magnify_ratio);

Or, to deselect all items:

for (int i = 0; i < combo_box->ListBox->Items->Count; i++)
    combo_box->ListBox->ListItems[i]->IsSelected = false;

But, how can I do the same for the ListBox of a TComboEdit in the OnPopup event? I got an error:

[bcc32c Error]: no member named 'ListBox' in 'Fmx::Comboedit::TComboEdit'


Solution

  • Try type-casting the TComboEdit::Presentation property to TStyledComboEdit and then use the TStyledComboEdit::ListBox property, eg:

    #include <FMX.ComboEdit.Style.hpp>
    
    static_cast<TStyledComboEdit*>(combo_box->Presentation)->ListBox->...