wxListBox::FindString issue

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
gtafan
Earned some good credits
Earned some good credits
Posts: 146
Joined: Wed Mar 29, 2017 9:52 am

wxListBox::FindString issue

Post by gtafan » Wed Mar 28, 2018 11:19 am

In the documentation of wxListBox::FindString There is: "Finds an item whose label matches the given string.", but what if there are more then 1 item with such label? I gues it returns the very first item with that label, posibly I am wrong, but how to get the other items with that lebel?

User avatar
xaviou
Super wx Problem Solver
Super wx Problem Solver
Posts: 429
Joined: Mon Aug 21, 2006 3:18 pm
Location: Annecy - France
Contact:

Re: wxListBox::FindString issue

Post by xaviou » Wed Mar 28, 2018 12:15 pm

Hi
gtafan wrote:I gues it returns the very first item with that label
You're right.
gtafan wrote:how to get the other items with that lebel?
You'll have to make the search yourself :

Code: Select all

int iCount = myListBox->GetCount();
for (int i=0; i<iCount; ++i)
{
    if (myListBox->GetString(i) == _T("Searched string"))
    {
        // Do what you want with the item at index i
    }
}
Regards
Xav'
My wxWidgets stuff web page : [email protected]'s wxStuff

Post Reply