How to add all the items of treeview within the combobox?
-
hi,how are you? What code would do this? Please help me. Thanks!
-
hi,how are you? What code would do this? Please help me. Thanks!
I found the answer The code is
Private Sub FillComboBox()
Tv.PathSeparator = ">>>"
Dim nodes As New List(Of TreeNode)
Dim queue As New Queue(Of TreeNode)
Dim top As TreeNode
Dim nod As TreeNode
For Each top In Tv.Nodes
queue.Enqueue(top)
Next
While (queue.Count > 0)
top = queue.Dequeue
nodes.Add(top)
For Each nod In top.Nodes
queue.Enqueue(nod)
Next
End While
' nodes.Sort(System.Collections.Generic.IComparer(Of TreeView))
For i As Integer = 0 To nodes.Count - 1
GroupQuestionsCbo.Items.Add(nodes(i).FullPath)
Next
End Sub -
I found the answer The code is
Private Sub FillComboBox()
Tv.PathSeparator = ">>>"
Dim nodes As New List(Of TreeNode)
Dim queue As New Queue(Of TreeNode)
Dim top As TreeNode
Dim nod As TreeNode
For Each top In Tv.Nodes
queue.Enqueue(top)
Next
While (queue.Count > 0)
top = queue.Dequeue
nodes.Add(top)
For Each nod In top.Nodes
queue.Enqueue(nod)
Next
End While
' nodes.Sort(System.Collections.Generic.IComparer(Of TreeView))
For i As Integer = 0 To nodes.Count - 1
GroupQuestionsCbo.Items.Add(nodes(i).FullPath)
Next
End SubI'm glad you found your answer, because your question was very ambiguous.
Steve Jowett ------------------------- Real programmers don't comment their code. If it was hard to write, it should be hard to read.