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. Populating Treeview from DB - Stops at 3rd level

Populating Treeview from DB - Stops at 3rd level

Scheduled Pinned Locked Moved Visual Basic
databasehelplearning
1 Posts 1 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.
  • E Offline
    E Offline
    ErikKoz
    wrote on last edited by
    #1

    This is probably more of a beginner issue, but Im trying to populate a treeview based off the Northwind Database. The Top level is a list of countries, second level is a list of customers from that country, and 3rd level is supposed to be orderids from that country but it isnt populating. I know its stopping at my 'FillOrderIDs' but I cant seem to figure out why. I appreciate any advice,

    Private Sub FillCountries()
        Dim tcountry As String
        Dim tnode As TreeNode
        Dim tCountryTable As NorthwindDataSet.CountriesDataTable
        tCountryTable = Me.CountriesTableAdapter.GetCountriesData
        For Each trow As NorthwindDataSet.CountriesRow In tCountryTable
    
            tcountry = trow.Country
            tnode = New TreeNode
            tnode.Name = "Country"
            tnode.Text = tcountry
            Me.TreeView1.TopNode.Nodes.Add(tnode)
            FillCompanyNames(tcountry, tnode)
        Next
    End Sub
    
    Private Sub FillCompanyNames(ByVal country As String, ByVal parentnode As TreeNode)
        Dim tCompany As String
        Dim tnode As TreeNode
        Dim CustTable As NorthwindDataSet.CompanyNamesDataTable
        CustTable = Me.CompanyNamesTableAdapter.GetCustomersByCountry(country)
    
        For Each trow As NorthwindDataSet.CompanyNamesRow In CustTable
            tCompany = trow.CompanyName
            tnode = New TreeNode
            tnode.Name = "CompanyName"
            tnode.Text = trow.CompanyName
            tnode.Tag = trow.CompanyName
            parentnode.Nodes.Add(tnode)
            FillOrderIDs(tCompany, tnode)
        Next
    
    End Sub
    
    Private Sub FillOrderIDs(ByVal orderid As String, ByVal parentnode As TreeNode)
        Dim tnode As TreeNode
        Dim OrdTable As NorthwindDataSet.OrderIdsDataTable
        OrdTable = Me.OrderIdsTableAdapter.GetOrderIds(CompanyName)
    
        For Each trow As NorthwindDataSet.OrderIdsRow In OrdTable
            tnode = New TreeNode
            tnode.Name = "OrderID"
            tnode.Text = trow.OrderID
            tnode.Tag = trow.OrderID
            parentnode.Nodes.Add(tnode)
        Next
    End Sub
    
    Private Sub btnDisplay\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
        TreeView1.Nodes.Add("Countries")
        FillCountries()
    End Sub
    
    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