MFC virtual List Control LVFINDINFO

100 views Asked by At

I'm going to make a search function in mfc virtual list control

However, even if i change the search method, always output only the 0th row I don't know what the problem is.

i searched 0th column value

void CListControlDlg::OnBnClickedButton2()
{
    CListCtrl* ListCtrl = ((CListCtrl*)GetDlgItem(IDC_LIST1));

    CString aaaa;

    aaaa.Format("%d", 56);

        LVFINDINFO f1;
        f1.flags = LVFI_STRING;
        f1.psz = aaaa;
        f1.vkDirection = VK_DOWN; 


        int num = ListCtrl->FindItem(&f1, -1); 
        if (num == -1) {
        MessageBox(_T("검색 실패"), MB_OK);
        return;
        }

        ListCtrl->SetItemState(
            num,
            LVIS_FOCUSED | LVIS_SELECTED,
            LVIS_FOCUSED | LVIS_SELECTED
        );
        ListCtrl->EnsureVisible(num, true);
        ListCtrl->SetFocus();
}

if i click button focus always on zero row

0

There are 0 answers