Click here to Skip to main content
15,881,898 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: the fast ways to create a list Pin
desanti11-Dec-18 5:40
desanti11-Dec-18 5:40 
GeneralRe: the fast ways to create a list Pin
Eddy Vluggen11-Dec-18 6:39
professionalEddy Vluggen11-Dec-18 6:39 
QuestionFill Treeview using recursion Pin
sterenas7-Dec-18 10:15
sterenas7-Dec-18 10:15 
AnswerRe: Fill Treeview using recursion Pin
Eddy Vluggen8-Dec-18 0:12
professionalEddy Vluggen8-Dec-18 0:12 
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 
Hi Eddie,
Realized I need to add an extra level to the tree. Changed your code to add the ShopName to the list of Thingy. Did a For Each to add all shop names to the tree as a first stage (there's only a max of 10 anyway).
I then tried to first filter the tree by ShopName to then add the nodes according to your code, but I can't seem to figure it out. I think possibleParent tv.Nodes.Find is not taking into account my possibleShop tv.nodes.find ?
Would you have any suggestions on this one ?
Dank U Wel Smile | :)

VB
Dim data As List(Of Thingy) = New List(Of Thingy) From {
    New Thingy("SHOP 1", 15, "Uncategorized", 0),
    New Thingy("SHOP 1", 50, "Animals", 0),
    New Thingy("SHOP 1", 51, "Plants", 0),
    New Thingy("SHOP 1", 52, "Dogs", 50),
    New Thingy("SHOP 1", 53, "Small", 52),
    New Thingy("SHOP 1", 54, "Medium", 52),
    New Thingy("SHOP 1", 55, "Large", 52),
    New Thingy("SHOP 1", 56, "Trees", 51),
    New Thingy("SHOP 1", 57, "Flowers", 51),
    New Thingy("SHOP 1", 58, "White", 55),
    New Thingy("SHOP 1", 59, "Brown", 55),
    New Thingy("SHOP 2", 15, "Uncategorized", 0),
    New Thingy("SHOP 2", 50, "Animals", 0),
    New Thingy("SHOP 2", 51, "Plants", 0),
    New Thingy("SHOP 2", 52, "Dogs", 50),
    New Thingy("SHOP 2", 53, "Small", 52),
    New Thingy("SHOP 2", 54, "Medium", 52),
    New Thingy("SHOP 2", 55, "Large", 52),
    New Thingy("SHOP 2", 56, "Trees", 51),
    New Thingy("SHOP 2", 57, "Flowers", 51),
    New Thingy("SHOP 2", 58, "White", 55),
    New Thingy("SHOP 2", 59, "Brown", 55)
}

' Add all shops to the tree
For Each item As Thingy In data
    Dim possibleShop As TreeNode() = tv.Nodes.Find(item.ShopName, searchAllChildren:=True)
    If possibleShop.Count = 0 Then
        tv.Nodes.Add(key:=item.ShopName, text:=item.ShopName)
    End If
Next

For Each item As Thingy In data
    Dim possibleShop As TreeNode() = tv.Nodes.Find(item.ShopName, searchAllChildren:=True)
    If possibleShop.Count > 0 Then
        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
    End If
Next

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 
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 

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.