Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to add all the items of treeview within the combobox?

How to add all the items of treeview within the combobox?

Scheduled Pinned Locked Moved Visual Basic
helptutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Milad Biroonvand
    wrote on last edited by
    #1

    hi,how are you? What code would do this? Please help me. Thanks!

    M 1 Reply Last reply
    0
    • M Milad Biroonvand

      hi,how are you? What code would do this? Please help me. Thanks!

      M Offline
      M Offline
      Milad Biroonvand
      wrote on last edited by
      #2

      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

      S 1 Reply Last reply
      0
      • M Milad Biroonvand

        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

        S Offline
        S Offline
        Steven J Jowett
        wrote on last edited by
        #3

        I'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.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups