|
-
Jul 6th, 2004, 10:37 AM
#1
Thread Starter
Lively Member
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.
-
Jul 6th, 2004, 11:49 AM
#2
Hyperactive Member
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:
Private Function PopTree(ByVal tvNode As TreeNode) As TreeNode
Dim tvNodes() As TreeNode, Index As Int16
ReDim tvNodes(9)
For Index = tvNodes.GetLowerBound(0) To tvNodes.GetUpperBound(0)
tvNodes(Index) = New TreeNode("Item_" & Index.ToString)
Next
tvNode.Nodes.AddRange(tvNodes)
Return tvNode
End Function
Private Sub btnGetCustInfo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetCustInfo.Click
Dim rootNode As New TreeNode("Root")
PopTree(rootNode)
Me.TreeView1.Nodes.Add(rootNode)
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|