hello and hi ...
am having a serious situation and i will bevery gratefull if you give me a hint
the problem:
am working on an accounting system and on a certian stage the user picks a main account, then a treeview should show all the sub accounts as child nodes,and every child node can have other childs...etc, there might be 3,5,or even 1000 sub accounts, so i need the treeview to be generated according to the number of sub accounts....
i tried this but the tree i made is verrrrrry static
CODE
For i As Integer = 0 To DataGridView1.Rows.Count - 1
If DataGridView1.Rows(i).Cells(1).Value = "1" Then
TreeView1.Nodes.Add(DataGridView1.Rows(i).Cells(0).Value)
' TreeView1.Nodes.Item(i).Name = DataGridView1.Rows(i).Cells(0).Value
'TreeView1.Nodes.AddRange(DataGridView1.Rows(i).Cells(2).Value)
End If
' If i < TreeView1.Nodes.Count Then
If DataGridView1.Rows(i).Cells(1).Value = "2" Then
For y As Integer = 0 To TreeView1.Nodes.Count - 1
If DataGridView1.Rows(i).Cells(3).Value = TreeView1.Nodes.Item(y).Text Then
TreeView1.Nodes(y).Nodes.Add(DataGridView1.Rows(i).Cells(0).Value)
'MessageBox.Show(TreeView1.Nodes(y).Nodes.Item(y).Text)
'
For a As Integer = 0 To TreeView1.Nodes(y).Nodes.Count - 1
TreeView1.Nodes(y).Nodes.Item(a).Name = DataGridView1.Rows(i).Cells(0).Value
' MessageBox.Show(TreeView1.Nodes(y).Nodes.Item(a).Name)
Next
End If
Next
End If
If DataGridView1.Rows(i).Cells(1).Value = "3" Then
For y As Integer = 0 To TreeView1.Nodes.Count - 1
For a As Integer = 0 To TreeView1.Nodes(y).Nodes.Count - 1
If DataGridView1.Rows(i).Cells(3).Value = TreeView1.Nodes(y).Nodes.Item(a).Text Then
TreeView1.Nodes(y).Nodes(a).Nodes.Add(DataGridView1.Rows(i).Cells(0).Value)
' MessageBox.Show("gfdgdf")
End If
Next
Next
End If
If DataGridView1.Rows(i).Cells(1).Value = "4" Then
For y As Integer = 0 To TreeView1.Nodes.Count - 1
For a As Integer = 0 To TreeView1.Nodes(y).Nodes.Count - 1
For k As Integer = 0 To TreeView1.Nodes(y).Nodes(a).Nodes.Count - 1
If DataGridView1.Rows(i).Cells(3).Value = TreeView1.Nodes(y).Nodes(a).Nodes.Item(k).Text Then
TreeView1.Nodes(y).Nodes(a).Nodes(k).Nodes.Add(DataGridView1.Rows(i).Cells(0).Value)
End If
Next
Next
Next
End If
' End If
Next
this is my e_mail: omary.anas@yahoo.com