Click here to Skip to main content
15,890,609 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Fill Treeview using recursion Pin
Eddy Vluggen8-Dec-18 1:46
professionalEddy Vluggen8-Dec-18 1:46 
GeneralRe: Fill Treeview using recursion Pin
sterenas8-Dec-18 4:26
sterenas8-Dec-18 4:26 
GeneralRe: Fill Treeview using recursion Pin
Eddy Vluggen8-Dec-18 4:37
professionalEddy Vluggen8-Dec-18 4:37 
GeneralRe: Fill Treeview using recursion Pin
sterenas10-Dec-18 3:52
sterenas10-Dec-18 3:52 
GeneralRe: Fill Treeview using recursion Pin
Eddy Vluggen11-Dec-18 2:08
professionalEddy Vluggen11-Dec-18 2:08 
GeneralRe: Fill Treeview using recursion Pin
sterenas11-Dec-18 5:34
sterenas11-Dec-18 5:34 
GeneralRe: Fill Treeview using recursion Pin
Eddy Vluggen11-Dec-18 6:16
professionalEddy Vluggen11-Dec-18 6:16 
GeneralRe: Fill Treeview using recursion Pin
sterenas11-Dec-18 7:51
sterenas11-Dec-18 7:51 
Great explanation Eddie, you nailed it! Enclosing the working code just in case someone else is as stuck as I was. You only need to add a treeview named tv to Form1.
Again thanks so much for your time and help and Heb een geweldige dag in zo'n mooi land.
Sergio

VB
Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim data As List(Of Thingy) = New List(Of Thingy) From {
            New Thingy(99999, "Shops", 0),
            New Thingy(1, "Shop 1", 99999),
            New Thingy(2, "Shop 2", 99999),
            New Thingy(15, "Uncategorized", 1),
            New Thingy(15, "Uncategorized", 2),
            New Thingy(50, "Animals", 1),
            New Thingy(51, "Plants", 1),
            New Thingy(52, "Dogs", 50),
            New Thingy(53, "Small", 52),
            New Thingy(54, "Medium", 52),
            New Thingy(55, "Large", 52),
            New Thingy(56, "Trees", 51),
            New Thingy(57, "Flowers", 51),
            New Thingy(58, "White", 55),
            New Thingy(59, "Brown", 55)
        }

        For Each item As Thingy In data
            Dim possibleParent As TreeNode() = tv.Nodes.Find(item.ParentCategory, searchAllChildren:=True)
            If possibleParent.Count = 0 Then
                tv.Nodes.Add(key:=item.IdCategory, text:=item.CategoryName)
            Else
                possibleParent.First().Nodes.Add(key:=item.IdCategory, text:=item.CategoryName)
            End If
        Next
        tv.ExpandAll()
    End Sub
End Class

Public Class Thingy
    Sub New(id As Long, catName As String, parentId As Long)
        IdCategory = id
        CategoryName = catName
        ParentCategory = parentId
    End Sub
    Public IdCategory As Long
    Public CategoryName As String
    Public ParentCategory As Long
End Class

GeneralRe: Fill Treeview using recursion Pin
Eddy Vluggen11-Dec-18 23:10
professionalEddy Vluggen11-Dec-18 23:10 
Questionentity framework Group by multiple columns and count the number of groups with more than 1 item Pin
desanti6-Dec-18 11:24
desanti6-Dec-18 11:24 
AnswerRe: entity framework Group by multiple columns and count the number of groups with more than 1 item Pin
Richard Deeming7-Dec-18 7:46
mveRichard Deeming7-Dec-18 7:46 
QuestionProblems with Entity Famework and bindingsources Pin
desanti6-Dec-18 0:13
desanti6-Dec-18 0:13 
QuestionDrawlines is correct or not ? Pin
Coffee_Break5-Dec-18 1:27
Coffee_Break5-Dec-18 1:27 
AnswerRe: Drawlines is correct or not ? Pin
Eddy Vluggen5-Dec-18 2:05
professionalEddy Vluggen5-Dec-18 2:05 
Questionsave my excel invoice in excel sheet Pin
kami1244-Dec-18 8:04
kami1244-Dec-18 8:04 
QuestionRe: save my excel invoice in excel sheet Pin
Richard MacCutchan4-Dec-18 8:58
mveRichard MacCutchan4-Dec-18 8:58 
QuestionError ContextSwitchDeadlock Pin
desanti4-Dec-18 5:33
desanti4-Dec-18 5:33 
AnswerRe: Error ContextSwitchDeadlock Pin
Eddy Vluggen4-Dec-18 6:33
professionalEddy Vluggen4-Dec-18 6:33 
GeneralRe: Error ContextSwitchDeadlock Pin
desanti4-Dec-18 8:45
desanti4-Dec-18 8:45 
GeneralRe: Error ContextSwitchDeadlock Pin
Eddy Vluggen4-Dec-18 9:37
professionalEddy Vluggen4-Dec-18 9:37 
GeneralRe: Error ContextSwitchDeadlock Pin
desanti5-Dec-18 1:18
desanti5-Dec-18 1:18 
GeneralRe: Error ContextSwitchDeadlock Pin
Eddy Vluggen5-Dec-18 1:43
professionalEddy Vluggen5-Dec-18 1:43 
GeneralRe: Error ContextSwitchDeadlock Pin
desanti5-Dec-18 2:08
desanti5-Dec-18 2:08 
GeneralRe: Error ContextSwitchDeadlock Pin
Eddy Vluggen5-Dec-18 2:37
professionalEddy Vluggen5-Dec-18 2:37 
GeneralRe: Error ContextSwitchDeadlock Pin
desanti5-Dec-18 2:49
desanti5-Dec-18 2:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.