我用的是
m_lstLink.InsertItem(0, "");
m_lstLink.SetItemText(0, 0, "test1");
m_lstLink.InsertItem(0, "");
m_lstLink.SetItemText(0, 0, "test2");可是插入后test2显示在test1的上面?请问有什么方法可以使插入后test2排在test1的下面?还有插入完成后怎么查找test2的index?

解决方案 »

  1.   

    m_lstLink.InsertItem(0, "");
    m_lstLink.SetItemText(0, 0, "test1");
    m_lstLink.InsertItem(1, "");
    m_lstLink.SetItemText(1, 0, "test2");
      

  2.   

    int ind = m_lstLink.InsertItem(  m_lstLink.GetItemCount() , "");
    m_lstLink.SetItemText(ind , 0, "test1");
    ind = m_lstLink.InsertItem( m_lstLink.GetItemCount() , "");
    m_lstLink.SetItemText(ind , 0, "test2");
      

  3.   

    CListCtrl::FindItem
    int FindItem( LVFINDINFO* pFindInfo, int nStart = -1 ) const;Return ValueThe index of the item if successful or -1 otherwise.ParameterspFindInfoA pointer to aLVFINDINFO structure containing information about the item to be searched for. nStartIndex of the item to begin the search with, or -1 to start from the beginning. The item at nStart is excluded from the search if nStart is not equal to -1.ResUse this function to search for a list view item having specified characteristics.The pFindInfo parameter points to an LVFINDINFO structure, which contains information used to search for a list view item.Example// The pointer to my list view control.
    extern CListCtrl* pmyListCtrl;
    // The string to match.
    extern LPCTSTR lpszmyString;LVFINDINFO info;
    int nIndex;info.flags = LVFI_PARTIAL|LVFI_STRING;
    info.psz = lpszmyString;// Delete all of the items that begin with the string lpszmyString.
    while ((nIndex=pmyListCtrl->FindItem(&info)) != -1)
    {
       pmyListCtrl->DeleteItem(nIndex);
    }
      

  4.   

    我用了楼上的方法还是不行啊,
    我的是
    lvcol.mask= LVCF_FMT|LVCF_SUBITEM|LVCF_TEXT|LVCF_WIDTH;
        lvcol.fmt= LVCFMT_LEFT;
    这个是不是有问题?
      

  5.   

    int ind = m_lstLink.InsertItem(  m_lstLink.GetItemCount() , "");
    m_lstLink.SetItemText(ind , 0, "test1");
    ind = m_lstLink.InsertItem( m_lstLink.GetItemCount() , "");
    m_lstLink.SetItemText(ind , 0, "test2");
    我试了这个,可是不行啊