CListCtrl Selection 
Author Message
 CListCtrl Selection

I'm trying to remove several items from a list control whenever a user
selects a specific item.

For example: if they select the 6th item, then I want to remove the 4
items above the 6th item and I want the item that I originally
selected (6th item now the 2nd item) to remain selected and maintain
the focus.

void CLstCtrlHideShowTestDlg::OnItemchangedList1(NMHDR* pNMHDR,
        LRESULT* pResult)
{
        NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
        bool bOldSelected = (bool)(pNMListView->uOldState & LVIS_SELECTED);
        bool bNewSelected = (bool)(pNMListView->uNewState & LVIS_SELECTED );

        if (bNewSelected && !bOldSelected)
        {
                if(pNMListView->iItem == 5)
                {
                        // simulate collapse
                        m_lstXSellOffers.SetRedraw(FALSE);
                        m_lstXSellOffers.DeleteItem(1);
                        m_lstXSellOffers.DeleteItem(1);
                        m_lstXSellOffers.DeleteItem(1);
                        m_lstXSellOffers.DeleteItem(1);
                        m_lstXSellOffers.SetRedraw(TRUE);
                }
        {

Quote:
}

The 6th item is now the 2nd item in the list and it correctly has the
focus rectangle but it is not selected.  However, if I use the
keyboard instead of the mouse, everything works correctly.

I've tried using SetItemState but still not working.  Does the
DeleteItem remove the selection mask after it is complete?  Is the
NM_CLICK doing something even though I haven't overriden this
function?
Any suggestions appreciated.
Thanks,
Merrell



Mon, 12 Sep 2005 18:17:57 GMT  
 CListCtrl Selection
One solution is to set the item state to selected.  Call
SetFocus().

Kuphryn



Mon, 12 Sep 2005 20:43:48 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. CListCtrl selection changed

2. CListCtrl selection problem

3. CListCtrl selection

4. CListCtrl Selection

5. Force CListCtrl selection

6. CListCtrl - Selection Styles

7. CListCtrl selection probs

8. Alternating CListCtrl Selection

9. CListCtrl selection

10. CListCtrl selection changed

11. Setting CListCtrl Selections

12. CListCtrl selection

 

 
Powered by phpBB® Forum Software