Position wxListBox

There are those times when it is convenient to position the list box to a specific location.

What we desire is to position the list box to a specific location.  You must know the exact entry text to use this feature.  To utilize a feature to position the list box to the first item containing the search string the following code provides the functionality.

[codesyntax lang=”cpp”]

void pDocFrame::OnpumPosSelected(wxCommandEvent& event)
    string sv = GetText(false, "", "Select Search String Now!", "Search String");
    int iend = lbxRecs->GetCount();
    int ii = 0;
    while (ii < iend)
        string buf;
        buf =  lbxRecs->GetString(ii).ToStdString();
        if (buf.find(sv) < buf.length())
            ii = iend + 1;



The data entry dialog to collect the string is a follows:

After the string is specified the list is positioned as follows.

From this point simply traverse in a downward direction of revealing the remaining entries.

Mr. Arch Brooks, Software Engineer, Brooks Computing Systems, LLC authored this article.

Leave a Reply

Your email address will not be published. Required fields are marked *