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
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 201
Joined: Wed Mar 29, 2017 9:52 am

wxListBox::FindString issue

Post by gtafan »

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: 437
Joined: Mon Aug 21, 2006 3:18 pm
Location: Annecy - France
Contact:

Re: wxListBox::FindString issue

Post by xaviou »

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 : X@v's wxStuff
Post Reply