[Gambas-user] Accessing the Treeview Collection

Wally wally at ...2037...
Wed Dec 17 20:10:48 CET 2008


On Wed December 17 2008 15:45:35 Doriano Blengino wrote:
> Wally ha scritto:
> > On Wed December 17 2008 14:09:31 Doriano Blengino wrote:
> >> Wally ha scritto:
> >>> How to access all items in a Treeview using
> >>> not using movefirst, movenext etc. ?
> >>>
> >>> FOR EACH ...  IN Treeview ???
> >>> ....
> >>> NEXT
> >>>
> >>> regs wally
> >>
> >> Do this:
> >>
> >>   if not xxx.MoveFirst() then
> >>     repeat
> >>       xxx.item.xxx()      ' do things with the current item
> >>     until xxx.MoveNext()
> >>   endif
> >>
> >> TreeView.MoveXXX() return TRUE if there were no more items to move to.
> >>
> >> Hope this is enough for you to start.
> >>
> >> Regards,
> >> Doriano
> >
> > Hi Doriano,
> >
> > PUBLIC SUB Button2_Click()
> >
> >  IF NOT TreeView1.MoveFirst() THEN
> >     REPEAT
> >       'do things with the current item
> >        'xxx.item.xxx()
> >       'TextArea1.Text &= TreeView1.Item.Key()
> >       ' NOT AN OBJECT !
> >
> >       TextArea1.Text &= TreeView1.Item.Key & "\n"
> >       'give just the root-childs
> >     UNTIL TreeView1.MoveNext()
> >   ENDIF
> >
> > END
> >
> > I got only the root-childs with this code but i think
> > it should be possible with additional treeview.item.count and
> > treevie.item.children loops.
> > I presumed the trreview holds the items in a collection and
> > the collection objects are accessible via FOR EACH IN.
> >
> > regs wally
>
> Hmmm,
> docs say that MoveNext() iterates to "next children"; MoveBelow() goes
> to the "next visible item below".
> I don't see anything wrong, and MoveNext() should work. Indeed, I used
> this scheme (MoveFirst + MoveNext), and it seems to me that it works...
>
> ...ask Benoit.
>
> Regards,
> Doriano

 
I think the following code does it and its clear.
(except the "ugly" labels and goto's )
thx, for ideas how to make more brief.

 '##################################################################
PUBLIC SUB Button3_Click()
'get all keys from treeview
' GoTop start
TreeView1.MoveFirst
TextArea1.Text &= TreeView1.Item.Key & "\n"
GOTO CC

'CC CheckOnChild
CC:
IF NOT TreeView1.MoveChild()
TextArea1.Text &= TreeView1.Item.Key & "\n"
GOTO CC
ELSE 
TreeView1.MoveBack
GOTO CS
ENDIF 

'CS CheckOnSibling
CS:
IF NOT TreeView1.MoveNext()
TextArea1.Text &= TreeView1.Item.Key & "\n"
GOTO CC
ELSE 
TreeView1.MoveBack
GOTO CP
ENDIF 

'CP CheckOnParent
CP:
IF NOT TreeView1.MoveParent()
GOTO CS
ELSE 
TextArea1.Text &= "Finished" & "\n"
ENDIF 

END

'##################################################################

regs wally












More information about the User mailing list