Results 1 to 2 of 2

Thread: 3 Tier Treeview Population Problem

  1. #1

    Thread Starter
    Lively Member carl_mathews200's Avatar
    Join Date
    May 2004
    Location
    Wales, UK
    Posts
    94

    Question 3 Tier Treeview Population Problem

    Hi.

    I have a 3 tier application (gui, business and data connecting to an sql server database)

    My problem is this... I need to populate a treeview for a certain criteria (Department & Section).

    How would i go about this? I would pass the Department & Section to the business layer which would then run a query in the data layer. The function(s) i assume would have to be recursive because i dont know how many sub items of one item there will be, how would i then pass the tree structure back to the GUI and populate the treeview????

    Does that make any sense??

    Example DB Layout:

    ID Name Owner Department Section
    -----------------------------------------------------------------------
    1 Root Folder 1 0 A Dep A Sec
    2 Sub Folder 1 1 A Dep A Sec
    3 Sub Folder 2 1 A Dep A Sec
    4 Sub Folder 3 3 A Dep A Sec

    etc... etc....

    Thanks in advance.

  2. #2
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    This code will populate a nodes collection, attach the collection to a root node and return the root node back to the calling function.

    VB Code:
    1. Private Function PopTree(ByVal tvNode As TreeNode) As TreeNode
    2.         Dim tvNodes() As TreeNode, Index As Int16
    3.         ReDim tvNodes(9)
    4.         For Index = tvNodes.GetLowerBound(0) To tvNodes.GetUpperBound(0)
    5.             tvNodes(Index) = New TreeNode("Item_" & Index.ToString)
    6.         Next
    7.  
    8.         tvNode.Nodes.AddRange(tvNodes)
    9.         Return tvNode
    10.     End Function
    11.  
    12.     Private Sub btnGetCustInfo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetCustInfo.Click
    13.         Dim rootNode As New TreeNode("Root")
    14.         PopTree(rootNode)
    15.         Me.TreeView1.Nodes.Add(rootNode)
    16.     End Sub
    Whadayamean it doesn't work....
    It works fine on my machine!

Posting Permissions

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



Click Here to Expand Forum to Full Width