VB.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 300,365 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,436 people online right now. Registration is fast and FREE... Join Now!




dynamic treeview

 

dynamic treeview

omary.anas

2 Jul, 2009 - 06:32 AM
Post #1

New D.I.C Head
*

Joined: 22 Jun, 2009
Posts: 2

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

User is offlineProfile CardPM
+Quote Post


omary.anas

RE: Dynamic Treeview

2 Jul, 2009 - 06:37 AM
Post #2

New D.I.C Head
*

Joined: 22 Jun, 2009
Posts: 2

am very sorry for the size of my previous post...my bad

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: {REMOVED}
User is offlineProfile CardPM
+Quote Post

modi123_1

RE: Dynamic Treeview

2 Jul, 2009 - 07:15 AM
Post #3

Suiter #2
Group Icon

Joined: 12 Jun, 2008
Posts: 1,760



Thanked: 72 times
Dream Kudos: 150
My Contributions
How about your edit and/or close one post?
User is offlineProfile CardPM
+Quote Post

PsychoCoder

RE: Dynamic Treeview

2 Jul, 2009 - 07:59 AM
Post #4

Dyslexics Untie!
Group Icon

Joined: 26 Jul, 2007
Posts: 14,713



Thanked: 501 times
Dream Kudos: 11450
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

My Contributions
Topics merged, please do not create duplicates smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 08:44PM

Live VB.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month