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.
incremental search for wxlistctrl Topic is solved
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();
buscar.MakeLower();
if(m_IdxBusqueda >= m_pLstContactos->GetItemCount())
m_IdxBusqueda=0L;
wxString actual;
for(; m_IdxBusqueda < m_pLstContactos->GetItemCount(); m_IdxBusqueda++)
{
actual = m_pLstContactos->GetItemText(m_IdxBusqueda).MakeLower();
if(actual.Find(buscar)!=-1)
break;
}
if(m_IdxBusqueda==m_pLstContactos->GetItemCount())
{
// not found
m_IdxBusqueda=0L;
wxBell();
return;
}
// if were here, we found it, select it. and record the last idx position
m_pLstContactos->EnsureVisible(m_IdxBusqueda);
m_pLstContactos->Select(m_IdxBusqueda);
m_IdxBusqueda++;
m_pLstContactos->SetFocus();
}
Hier Kommt die Sonne...