CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 1999
    Posts
    2

    Need help with Tree View

    Hi,

    How can I store some information in Tree View control.

    Thanks.


  2. #2

    Re: Need help with Tree View

    if you want remenber data with treectrl item look here
    pParam is pointer to my alocated structure
    TV_INSERTSTRUCT TreeCtrlItem;
    TreeCtrlItem.hParent = hParentItem;
    TreeCtrlItem.hInsertAfter = TVI_LAST;
    TreeCtrlItem.item.mask = /*TVIF_TEXT |*/ TVIF_PARAM;
    //TreeCtrlItem.item.pszText = pParam->m_pName;
    TreeCtrlItem.item.lParam = (long)pParam;
    HTREEITEM hLayTreeItem = m_TreeCtrl.InsertItem(&TreeCtrlItem);
    at program/window exit you must this date delete, for example
    delete((CHItemParam*)(m_TreeCtrl.GetItemData(hItem)));
    if you need store data in any m_TreeCtrl class member which is not visible but used for data storing only call (and text success) of m_TreeCtrl.Create before adding items
    maybe this helps you


  3. #3
    Join Date
    May 1999
    Location
    Farnborough, Hants, England
    Posts
    710

    Re: Need help with Tree View

    Each tree node supports a DWORD value like a list box does, accessed using GetItemData() and SetItemData(). This could be used to point to a structure or class (created in memory) which holds the extra information you need for each node. If the data to be stored is small enough, such as an index into a list of functions to perform when the branch is selected, for example, then the information could simply be stored in the DWORD itself, i.e.: SetItemData(hItem,(DWORD)iFnIndex);

    Does this help?

    --
    Jason Teagle
    [email protected]

  4. #4
    Join Date
    Apr 1999
    Posts
    2

    Re: Need help with Tree View

    Thanks.Your suggestion did help me.

    ban


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