How to find all expanded items in a treectrl? Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
fox287
Earned a small fee
Earned a small fee
Posts: 15
Joined: Sat Aug 01, 2009 12:12 pm

How to find all expanded items in a treectrl?

Post by fox287 » Wed Aug 05, 2009 6:46 pm

Hi,


I need to find all expanded items of a treectrl, but don't know how to do that.

I am a little bit confused with the use of getnextchild, because it doesn't provide the children of a treectrl-child.

Is there a easy way to loop through all items of a treectrl (including their children and their children, ...)?


Hope smb can help

van_user
Experienced Solver
Experienced Solver
Posts: 55
Joined: Wed Jun 11, 2008 9:28 pm
Location: UA

Post by van_user » Thu Aug 06, 2009 8:33 am

wxTreeCtrl::IsExpanded

loop through all items:
after find first expanded item

Code: Select all

funtion Lookup( Item* item_e)
{
  if item_e -> IsExpanded( )
    return item_e -> GetFirstChildren( );
  next_item = item_e -> GetNextSubling( );
    while( next_item not valid)
    {
      if( next_item == root_item)
        return finish;//NULL
      next_item = next_item -> GetItemParent( ) -> GetNextSubling( );
    }
  return next_item;
}
or simply use wxTreeCtrl::GetNextVisible ( try, I don`t worked with it)
Last edited by van_user on Fri Aug 07, 2009 5:24 am, edited 1 time in total.
Win XP (SP0), mingw, wx 2.9.0

fox287
Earned a small fee
Earned a small fee
Posts: 15
Joined: Sat Aug 01, 2009 12:12 pm

Post by fox287 » Thu Aug 06, 2009 5:50 pm

Thats exactly what I was looking for - thank you very much.

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Thu Aug 06, 2009 10:50 pm

Please accept the post that helped you, and not yours. Thanks
"Keyboard not detected. Press F1 to continue"
-- Windows

Post Reply