Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Losing my mind, treeviews are killing me

Status
Not open for further replies.

gudisdum

Programmer
Jun 13, 2003
13
NL
I am coding the user interface for a database that tracks different types of personell issues. I was givin an outline that they want in a treeview. Kind of like this:
I Unsafe Acts
A. Errors
1. Skill Based
a. No turn over
This outline goes about 4 deep and has many roots. The problem I have is that they want to be able to add to it at run time. So my code has to pull the path from the database and build the treeview at run time. I cannot find a way to go deeper then 3 levels using FirstNode and NextNode. I have both the full path and the previous node stored in the database to use.

Could someone take a look at the code I am using now and give me any thoughts on how I can better get through this.

Thanks much

The dimed portion of the code doesn't work at all.
Private Sub frmCatIn_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.daCatIn.Fill(Me.DsCatIn1.Catagory)
Dim x As Integer
For x = 0 To Me.DsCatIn1.Catagory.Count - 1
Skip = False
there = False
Dim y As Integer
If Me.DsCatIn1.Catagory(x).IsTieNull Then
Me.TreeView1.Nodes.Add(Me.DsCatIn1.Catagory(x).Cat)
Else
Dim strTree As String
Dim t As TreeNode

For Each t In Me.TreeView1.Nodes
If t.Text = Me.DsCatIn1.Catagory(x).Tie Then
If Not t.FirstNode Is Nothing Then
If Not t.FirstNode.Text = Me.DsCatIn1.Catagory(x).Cat Then
t.Nodes.Add(Me.DsCatIn1.Catagory(x).Cat)
End If
Else
t.Nodes.Add(Me.DsCatIn1.Catagory(x).Cat)
End If
End If
If Not t.FirstNode Is Nothing Then
If t.FirstNode.Text = Me.DsCatIn1.Catagory(x).Tie Then
If Not t.NextNode Is Nothing Then
If Not t.NextNode.Text = Me.DsCatIn1.Catagory(x).Cat Then
t.FirstNode.Nodes.Add(Me.DsCatIn1.Catagory(x).Cat)
End If
Else
t.FirstNode.Nodes.Add(Me.DsCatIn1.Catagory(x).Cat)
End If
End If
End If
'If Not t.FirstNode.FirstNode Is Nothing Then
' If t.FirstNode.FirstNode.Text = Me.DsCatIn1.Catagory(x).Tie Then
' If Not t.FirstNode.FirstNode Is Nothing Then
' If Not t.FirstNode.FirstNode.Text = Me.DsCatIn1.Catagory(x).Cat Then
' t.FirstNode.FirstNode.Nodes.Add(Me.DsCatIn1.Catagory(x).Cat)
' End If
' Else
' t.FirstNode.NextNode.Nodes.Add(Me.DsCatIn1.Catagory(x).Cat)
' End If
' End If
'End If

Next
End If
Next
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top