Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting the count of a collection
Message
 
To
04/10/1997 17:39:45
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00053257
Message ID:
00053274
Views:
27
>>>>>>>In the treeview, I would like to get the count of a collection. I can't find the correct syntax.
>>>>>>
>>>>>>ThisForm.Olecontrol1.Nodes.Count returns the total number of items in the collection. Is this what you're looking for?
>>>>>
>>>>>No, I am looking for the count of the current collections. This mean all the children related to the current node.
>>>>
>>>>I thought that's what you might be looking for. The only way I know is to loop through the collection and count the instances where the .Key property contains the string you're looking for. Naturally, the number of children will be one less than the total.
>>>
>>>According to the help, we should be able to get the count of a collection. Which mean, from any level in the treeview, requested a command should give us the total number of children.
>>>
>>>For now, yes, I am doing a loop but this is not what I want. :)
>>
>>I did have one thought which might speed things up if the treeview is sorted. You could do a binary search to determine the starting point and with a DO WHILE...ENDDO loop terminate it when the end of the matches occurred. This might make a difference if the number of items in the treeview was large.
>
>This is similar to what I do. I only loop in the portion I need to count.

Great minds think alike, right Michel? :-)

BTW, I'd agree with you about having access (no pun intended, despite my reputation) to the number of children if the .Nodes collection was recursively defined. Apparently, it isn't. If it was, you could access the total number of children via:

ThisForm.TreeView.Nodes(lnindex).Nodes.Count

The only other property that might apply is .Children, but that only returns the number of immediate children, and doesn't include children of children. You might be able to get that with a recursive function.

George
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform