Forum Discussion
If there are any static properties that would uniquely identify them you could use FindChild to find the matching item.
I know only the Text of the particular tree item nothing else.
If i want to find a tree item based on its text, How i can do that.
And the tree items are nested so i don't know on which thisngs it theres
- tristaanogre10 years agoEsteemed Contributor
FindChild and related methods allow you to search in your tree of objects for any child given a particular set of properties. So, if you only know the text, you would call something like
... var PropertyList = new Array("Text") var PropertyValues = new Array("MyText") ... var MyTreeItem = ParentObj.FindChild(PropertyList, PropertyValues, 5)See FindChild Method
- shankar_r10 years agoCommunity Hero
I tried the option which you have described. But
TreeObject
1.TreeItem1
1.1 MainTopic
1.1.1 TestTopic
1.1.1.1 HaveToClick
1.1.1.1 HaveToClick is child of 1.1.1 TestTopic, I am having only the 1.TreeItem1 object.
If i use like this below,
var PropertyList = new Array("Text") var PropertyValues = new Array("1.1.1.1 HaveToClick") ... var MyTreeItem = 1.TreeItem1(Object).FindChild(PropertyList, PropertyValues, 5)It won't get the 1.1.1.1 HaveToClick.
- tristaanogre10 years agoEsteemed Contributor
The 5 in my sample code is the depth down the object tree to search for what you are looking for. You may need to expand that to a higher number.
Additionally, the Text property was just a pseudo-code value that I put in to give context... you may need to change that to actually correspond to the property on 1.1.1.1 HaveToClick that contains the text you are searching for. Ultimately, FindChild is the easiest way to find what you want so long as the item you are looking for is actually a child object. In other words, if you can call
Aliases.TreeObject.TreeItem1.MainTopic.TestTopic.HaveToClick
Then you can use
Aliases.TreeObject.FindChild(PropertyList, PropertyValues) to find your object assuming you are passing in the appropriate properties and their corresponding values.