SPONSORS:






User Tag List

Results 1 to 5 of 5
  1. #1
    Member
    Join Date
    Jun 2002
    Location
    california
    Posts
    60
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Multi-level treeviews

    I have a treeview in my application that has this kind of hierarchy...

    Tree
    |_ Branch1
    |___ Leaf1
    |___ Leaf2
    |__ Leaf2a
    |_ Branch2

    In the above sample tree, let's say i would like to figure out the total number of child objects in the tree inclusive of the leaves and subleaves. How do I do that? Is there an available method in SilkTest? I look GetSubItemCount() but it only goes through one level. Any ideas and suggestions. Thanks!

    ------------------

  2. #2
    Senior Member
    Join Date
    May 2002
    Posts
    448
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Multi-level treeviews

    At present it is a bit tricky. But refer the method below, this helps to expand all the items in a treeview. Maybe this could give you a start. We can overwrite the GetSubItemCount () method on similar basis to expand all children of a specific item and return the contents. Will get back to you.

    Hope this helps,




    [This message has been edited by witchcrop (edited 07-03-2002).]
    Life, that dares send, A challenge to his end,
    And when it comes say, Welcome friend.

  3. #3
    Member
    Join Date
    Jun 2002
    Location
    california
    Posts
    60
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Multi-level treeviews

    thanks witchcrop. actually, i created a function that will expand my treeview. 2 level treeview i was able to access the subitems but more levels than that becomes a problem.

    please let me know if you found anything for the subcontents. thanks.

    ------------------

  4. #4
    Senior Member
    Join Date
    May 2002
    Posts
    448
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Multi-level treeviews

    Whola!

    Well there is more than one issure here,
    1) If you want to know that total number of items in a treeview then the method GetItemCount () is usefull. Here all we have to do is pass the argument to the method as True which will return the total number of items in the treeview irrespective of whether hidden or collapsed.

    2) If you want to know the total number of items (children) of a particular item of a treeview, then the method copied below should help you to do so. I hope this method should work for more than 2 levels of tree. Let me know about this.

    This method will expand only the members of the item whose children you want to know. And return you the total number of children of the specified item. I have used a sample application there, so use it as it applies to you.

    3) If you want to know the total Contents of the treeview then GetContents () should be enough, but if you want to know the enitre contents (including immediate children and therafter) of a particular item, then we will have to create a custom class for treeview and overwrite the GetContents method. Also here as is the case of GetItemCount (), the function returns only the items that are viewable, so we can use the method in conjunction with the one posted earlier (to expand the entire treeview) or the one mentioned above (which only expands a specific item completely).

    I hope i was of some help. Keep us posted.

    ------------------
    never say die

    [This message has been edited by witchcrop (edited 07-04-2002).]
    Life, that dares send, A challenge to his end,
    And when it comes say, Welcome friend.

  5. #5
    Member
    Join Date
    Jun 2002
    Location
    california
    Posts
    60
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Multi-level treeviews

    thanks witchcrop for your suggestion.

    this is what i have come up with. i made sure that the treeview is expanded using my customized function.

    i captured the item count using listcount() instead.

    [-] integer Cust_GetSubItemCount(STRING sObject, WINDOW wTreeView)
    [ ]
    [ ] ExpandAllTreeView (wTreeView)
    [ ]
    [ ] list of string lsChild = {}
    [ ] list of string lsObjects = wTreeView.TreeView1.GetContents ()
    [ ] integer i
    [ ]
    [-] for i = 1 to ListCount (lsObjects)
    [ ] boolean bIsItAFolder = IsItAFolder (lsObjects[i], wTreeView)
    [-] if (MatchStr ("/*"+sObject+"*", lsObjects[i])) && (bIsItAFolder == false)
    [ ] ListAppend(lsChild, lsObjects[i])
    [ ]
    [ ] //subtract 1 not to include parent
    [ ] integer iCount = ListCount (lsChild) - 1
    [ ]
    [-] return (iCount)


    ------------------

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 09:25 PM.

Copyright BetaSoft Inc.