firemonkeyc++builder-10.2-tokyo

Clear Firemonkey TListView search text (C++)


I want to clear the ListView's search box text in C++. Here is a link to doing this in pascal but I've been unable to convert this to C++ (due to my ignorance).

Seems like it should be something simple like:

ListView1->SearchBox->Clear();

thanks, russ


Solution

  • #include <FMX.SearchBox.hpp>
    
    TSearchBox *SearchBox_ListView1 = nullptr;
    
    ...
    
    for(int i = 0; i < ListView1->Controls->Count; ++i)
    {
        SearchBox_ListView1 = dynamic_cast<TSearchBox*>(ListView1->Controls[i]);
        if (SearchBox_ListView1)
            break;
    }
    
    ... 
    
    if (SearchBox_ListView1)
        SearchBox_ListView1->Text = L"";