incremental search for wxlistctrl Topic is solved

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
Knows some wx things
Knows some wx things
Posts: 42
Joined: Tue Dec 20, 2005 3:08 pm

incremental search for wxlistctrl

Post by fhd » Thu Feb 23, 2006 8:37 pm

Hi, I want an incremental search feature like in most native list controls for wxlistctrl,
I assume this is a very frequently used expansion of the listctrl, so I thought that someone might have written a method for this, but I cannot find anything.

For those of you that don't have a clue what I mean with incremental search, I'll tell an example:

You have a list with very much entries.
You know that your entry begins with a "t". You type a "t" in and the focus jumps to the first entry beginning with "t".
You also know, that the second letter in your desired entry is an "a", so you type an "a", and you get the first entry beginning with "ta".

... and so on .. that's incremenetal search.

I live to help wx-kind
I live to help wx-kind
Posts: 195
Joined: Wed Sep 28, 2005 9:42 pm

Post by cpp » Sun Feb 26, 2006 6:09 am

Heres how i do it. (im pasting this from one of my apps)

Code: Select all

// m_IdxBusqueda is an int member of the panel where the list is
// m_IdxBusqueda is reset to 0 whenever the list is created or
//   the user types something in the search box
// m_pLstContactos is the wxListView (also class member)
// m_pTxcBuscar is a textbox where user types what hes looking for
// this is called whenever the user presses ENTER in the search box

void PanelContactos::BuscarContacto()
    wxString buscar = m_pTxcBuscar->GetValue();

    if(m_IdxBusqueda >= m_pLstContactos->GetItemCount())

    wxString actual;
    for(; m_IdxBusqueda < m_pLstContactos->GetItemCount(); m_IdxBusqueda++)
        actual = m_pLstContactos->GetItemText(m_IdxBusqueda).MakeLower();
        // not found

    // if were here, we found it, select it. and record the last idx position
Hier Kommt die Sonne...

Post Reply