Expand TreeGadget

Just starting out? Need help? Post your questions and find answers here.
User avatar
BillyBob
User
User
Posts: 21
Joined: Fri Oct 15, 2010 1:02 am
Location: Canada

Expand TreeGadget

Post by BillyBob »

I have searched high and low and I can not figure out how to have the TreeGadget default to expanded. I have seen many references in this forum to what must be a old, and now non existent method of expanding the tree.

The suggestion in the user manual says to set the SetGadgetItemState with #PB_Tree_Expanded, well it is not working for me in a manner that is understandable or predictable. I am testing on WIN7. Any suggestions would be appreciated.

Thanks
PureLust
Enthusiast
Enthusiast
Posts: 477
Joined: Mon Apr 16, 2007 3:57 am
Location: Germany, NRW

Re: Expand TreeGadget

Post by PureLust »

BillyBob wrote:The suggestion in the user manual says to set the SetGadgetItemState with #PB_Tree_Expanded, well it is not working for me in a manner that is understandable or predictable. I am testing on WIN7. Any suggestions would be appreciated.
Hi BillyBob, ...

as you can see in the follwing code, #PB_Tree_Expanded works fine, like it should.

Code: Select all

If OpenWindow(0, 0, 0, 355, 180, "TreeGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    TreeGadget(0, 10, 10, 160, 160)                                         ; TreeGadget Standard
    TreeGadget(1, 180, 10, 160, 160, #PB_Tree_CheckBoxes|#PB_Tree_NoLines)  ; TreeGadget mit Checkboxen + ohne Linien
    For ID = 0 To 1
      For a = 0 To 10
        AddGadgetItem (ID, -1, "Normal Item "+Str(a), 0, 0) ; wenn Sie ein Bild hinzufügen möchten, dann 
        AddGadgetItem (ID, -1, "Node "+Str(a), 0, 0)        ; benutzen Sie ImageID(x) als 4. Parameter
        AddGadgetItem(ID, -1, "Sub-Item 1", 0, 1)     ; diese sind auf dem ersten Sublevel
        AddGadgetItem(ID, -1, "Sub-Item 2", 0, 1)
        AddGadgetItem(ID, -1, "Sub-Item 3", 0, 1)
        AddGadgetItem(ID, -1, "Sub-Item 4", 0, 1)
        AddGadgetItem (ID, -1, "File "+Str(a), 0, 0)  ; hier wieder Sublevel 0
      Next
    Next
    
    SetGadgetItemState(0, 1, #PB_Tree_Expanded)
    SetGadgetItemState(1, 8, #PB_Tree_Expanded)
    
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf
Greetz from Germany,
PL.
[Dynamic-Dialogs] - create complex GUIs the easy way
[DeFlicker] - easily deflicker your resizeable Windows
[WinFX] - Window Effects (incl. 'click-through' Window)
User avatar
BillyBob
User
User
Posts: 21
Joined: Fri Oct 15, 2010 1:02 am
Location: Canada

Re: Expand TreeGadget

Post by BillyBob »

I guess placement on of the SetGadgetItemState must be critical as I had originally placed this function after each AddGadgetItem and it did not work for me. However, when I arranged the order like you have suggested, all is working well.

THANK YOU VERY MUCH from Canada!
PureLust
Enthusiast
Enthusiast
Posts: 477
Joined: Mon Apr 16, 2007 3:57 am
Location: Germany, NRW

Re: Expand TreeGadget

Post by PureLust »

BillyBob wrote:THANK YOU VERY MUCH from Canada!
You are welcome. :mrgreen:
[Dynamic-Dialogs] - create complex GUIs the easy way
[DeFlicker] - easily deflicker your resizeable Windows
[WinFX] - Window Effects (incl. 'click-through' Window)
horst
Enthusiast
Enthusiast
Posts: 197
Joined: Wed May 28, 2003 6:57 am
Location: Munich
Contact:

Re: Expand TreeGadget

Post by horst »

BillyBob wrote:I guess placement on of the SetGadgetItemState must be critical as I had originally placed this function after each AddGadgetItem and it did not work for me.
Setting the #PB_Tree_Expanded state works well when you do it immediately after adding the first item on the sub-level:

SetGadgetItemState(#tree, item_number-1, #PB_Tree_Expanded)

Of course, this requires controlling the item_number.
Horst.
User avatar
Vera
Addict
Addict
Posts: 858
Joined: Tue Aug 11, 2009 1:56 pm
Location: Essen (Germany)

Re: Expand TreeGadget

Post by Vera »

Hello,

just dropped in to hint at Shardiks remarkable code of how to expand subitems onto a prescribed level: TreeGadget ganz entfalten ...

edit: removed additional remark as is was very Linux specific, as the pointed effects don't arise on Windows the same way.

greetings ~ Vera
Post Reply