PDA

View Full Version : i need to copy a text from tree to listbox



lnd
10-10-2005, 03:59 PM
i need to copy a text from tree to listbox.

tChildrenOfNode1 = Tree.GetChildren("Tree1", "1.1.1.1");
result = ListBox.AddItem("ListBox1", tChildrenOfNode1);

TJ_Tigger
10-10-2005, 06:54 PM
i need to copy a text from tree to listbox.

tChildrenOfNode1 = Tree.GetChildren("Tree1", "1.1.1.1");
result = ListBox.AddItem("ListBox1", tChildrenOfNode1);


The Tree.GetChildren action returns a table containing all the children under the specified node. You will need to use a for loop to enumerate the table and add the items to your listbox.



tChildrenOfNode1 = Tree.GetChildren("Tree1", "1.1.1.1");
--Make sure there are children in the table
if tChildrenOfNode1 then
--for each child found add it to the list box with the text as the LB text and the NodeIndex as the data
for i,v in tChildrenOfNode1 do
ListBox.AddItem("ListBox1", tChildrenOfNode1[i]["Text"]
, tChildrenOfNode1[i]["NodeIndex"])
end
end


As a helpful hint, make sure to pay attention to what is returned by the action.

HTH
Tigg

lnd
10-10-2005, 11:56 PM
i need to read only the text in node 1.1.1.1 in to a variable and put it into a listbox

TJ_Tigger
10-11-2005, 07:56 AM
i need to read only the text in node 1.1.1.1 in to a variable and put it into a listbox


Use the Tree.GetNode action instead.

Tigg

lnd
10-11-2005, 09:22 AM
i use this code

tChildrenOfNode1 = Tree.GetNode("Tree1", "1.1.1.1");
result = ListBox.AddItem("ListBox1", tChildrenOfNode1);

and get error messeg - must be of type string -

TJ_Tigger
10-11-2005, 09:50 AM
Exactly because the Tree.GetNode returns a table and not a string. You need to specify which column of data you want from the returned table.

tChildrenOfNode1 = Tree.GetNode("Tree1", "1.1.1.1");
result = ListBox.AddItem("ListBox1", tChildrenOfNode1.Text, "1.1.1.1");


Tigg

lnd
10-11-2005, 10:51 AM
Thank you Thank you Thank you....