Sorry I thought nobody wanted to see my crummy code.
I narrowed it down to only three columns to search for. Other were nonsense anyway.
Look and be amazed!
(translated for easier undestanding)
Code:
void CVaja6ListControlDlg::OnBtnFind()
{
// clean the list of previously selected items
int i=0;
while(i<m_cMyList.GetItemCount())
{
m_cMyList.SetItemState(i, 0, LVIS_SELECTED);
i++;
}
UpdateData();
CString readName;
CString readSurname;
CString readAge;
int numberChecks=3; // let's say all three check boxes were selected
// then we substract 1 if it was not checked
// if not checked we set some nonsense so there won't be a hit
if(!(m_chkByName))
{ m_name="ihopeyoudidntinputthis"; numberChecks--; }
if(!(m_chkBySurname))
{ m_surname="ihopeyoudidntinputthis"; numberChecks--; }
if(!(m_chkByAge))
{ m_age=9545; numberChecks--; }
// if no checboxes were checked we exit otherwise everything will be a hit
if(numberChecks==0) { return; }
int hits; // number of hits, if this equals numberChecks we have a complete hit
i=0;
m_cMyList.SetFocus(); // focus on listctrl so we can select
while(i<m_cMyList.GetItemCount())
{
hits=0;
readName = m_cMyList.GetItemText(i,0); // read from CListCtrl
readSurname = m_cMyList.GetItemText(i,1);
readAge = m_cMyList.GetItemText(i,2);
// compare what we read from CListCtrl with what was put into the edit boxes to search for
if(strcmp(readName,m_name)==0)
{ hits++; }
if(strcmp(readSurname,m_surname)==0)
{ hits++; }
CString strStarost;
strStarost.Format("%i", m_age);
if(strcmp(readAge,strStarost)==0)
{ hits++; }
if(numberChecks==hits) // if we have a complete hit
{
m_cMyList.SetItemState(i, LVIS_SELECTED, 0xFF);
}
i++;
}
// here I should scrool the list down to the last record found, but how??
}