Page 1 of 1

Expand TreeGadget

Posted: Mon Nov 01, 2010 4:28 am
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

Re: Expand TreeGadget

Posted: Mon Nov 01, 2010 11:32 am
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.

Re: Expand TreeGadget

Posted: Mon Nov 01, 2010 1:13 pm
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!

Re: Expand TreeGadget

Posted: Mon Nov 01, 2010 1:52 pm
by PureLust
BillyBob wrote:THANK YOU VERY MUCH from Canada!
You are welcome. :mrgreen:

Re: Expand TreeGadget

Posted: Mon Nov 01, 2010 5:05 pm
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.

Re: Expand TreeGadget

Posted: Tue Nov 02, 2010 12:11 am
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