CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Guest

    Id for a row in CListCtrl

    I have a linked list of objects that are displayed on a list control. When I double click on the row I want to be able to find the object
    in my linked list from the info in the row, possibly some kind of row id that I can save in my object. Is there a standard way to do
    this? I was thinking it had something to do with the lParam of the LV_ITEM structure, but I'm not sure how to use this.

    Thanks in advance.


  2. #2
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266

    Re: Id for a row in CListCtrl

    See CListCtrl::SetItemData and CListCtrl::GetItemData. I think the documentation has all the answers that you are seeking.


    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  3. #3
    Guest

    Re: Id for a row in CListCtrl

    You can save linked list pointer in your list control using SetItemData() and retrive pointer back by GetItemData().you need to cast pointer to DWORD and vise versa.

    like
    m_ptrlistObject is a pointer to a object in list
    pListCtrl->SetItemData(nIndex,(DWORD)m_ptrlistObject);

    retrive
    int nItem = pListCtrl->GetNextSelectedItem(pos);
    m_ptrlistObject=(yourobject*)pListCtrl->GetItemData(nItem);

    hope this works



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured