[Gambas-user] Treeview HELL...
sbungay
sbungay at ...981...
Sun Mar 4 14:42:29 CET 2007
Thank you Timothy.
The last attempt I made before heading off to sleep on it was as follows;
WITH TreeViewQuest
.MoveFirst
REPEAT
message.info(.Item.Key & ", " & .Item.Text)
.MoveNext
message.info(.Item.Key & ", " & .Item.Text)
UNTIL TreeViewQuest.MoveBelow()
END WITH
I was on the right track but being close doesn't count.
Now what we need is for the virtual TreeItem class to have a
ParentKey property in it. Since it doesen't have this I'll make up a
collection that uses the tree node keys as it's own keys and store the
node parent info in the collection. A little extra overhead but it
should work just fine.
Once again, my sincere thanks Timothy.
Steve.
timothy wrote:
>>-----Original Message-----
>>From: gambas-user-bounces at lists.sourceforge.net [mailto:gambas-user-
>>bounces at lists.sourceforge.net] On Behalf Of sbungay
>>Sent: Sunday, 04 March 2007 01:40 AM
>>To: GambasList
>>Subject: [Gambas-user] Treeview HELL...
>>
>> I'm trying to iterate through a treeview, the goal is to store the
>>treeview structure to a table (thats the easy part), the question is
>>'HOW can I traverse all nodes of a treeview using it's own methods?'
>>
>> The sample treeview control has a total of 5 nodes. One root node
>>which has two children and each child has a child (5 nodes in all)
>>
>> Treeview1.Count returns a value of one (I expected 5)
>>
>> Treeview1.movenext seems to do.. umm.. nothing at all.
>>
>> .MoveChild also seems to do nothing.
>>
>>For example, the following code;
>>
>>WITH TreeView1
>> .MoveFirst
>> message.info (.Item.Key & ", " & .Item.text)
>> .MoveNext
>> message.info (.Item.Key & ", " & .Item.text)
>>END WITH
>>
>> yields two messages with exactly the same information in them.
>>
>>
>>Steve.
>>
>>--You are in a maze of twisty little passages all alike.
>>
>>
>
>
>
> This example saves the content of a treeview to a file. Thought it takes
> no account of the hierarchy in the treeview:
>
> ' Save the TreeView content to a csv text file
> PUBLIC SUB ToolButtonSave_Click()
> DIM csvFile AS File
> IF TreeViewItems.Count = 0 THEN
> Message.Info("There are no items to save")
> RETURN
> END IF
> Dialog.Filter = ["*.csv", "Comma Separated Variable", "*.txt", "Text
> Files", "*", "All Files"]
> IF Dialog.SaveFile() THEN RETURN
> ' Open the file as CREATE for writing to.
> ' If the file does not exist it will be created and opened.
> ' If the file does exist then the file is cleared and opened.
> OPEN Dialog.Path FOR CREATE AS #csvFile
> ' For each item in the TreeView
> TreeViewItems.MoveFirst()
> REPEAT
> PRINT #csvFile, Quote(TreeViewItems.Item.Key) & "," &
> Quote(TreeViewItems.Item.Text)
> UNTIL TreeViewItems.MoveBelow()
> CLOSE #csvFile
> CATCH
> Message.Info("<b>Cannot save items:</b><br>" & Dialog.Path & "<hr>" &
> Error.Text)
> ' Make sure the file is closed. If the file is already closed
> ' or a null object then TRY will make sure we do not raise an error.
> TRY CLOSE #csvFile
> END
>
>
>
>
> Thanks
>
> 8-{)} Timothy Marshal-Nichols
> <mailto: timothy.marshal-nichols at ...247...>
>
>
>
>
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
More information about the User
mailing list