Click here to Skip to main content
15,917,174 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionGet the parent objet or parent level in nested lists Pin
norrisMiou4-Apr-10 0:51
norrisMiou4-Apr-10 0:51 
AnswerRe: Get the parent objet or parent level in nested lists Pin
DaveAuld4-Apr-10 2:28
professionalDaveAuld4-Apr-10 2:28 
GeneralRe: Get the parent objet or parent level in nested lists Pin
norrisMiou4-Apr-10 2:56
norrisMiou4-Apr-10 2:56 
GeneralRe: Get the parent objet or parent level in nested lists Pin
DaveAuld4-Apr-10 5:36
professionalDaveAuld4-Apr-10 5:36 
AnswerRe: Get the parent objet or parent level in nested lists Pin
Alan N4-Apr-10 6:04
Alan N4-Apr-10 6:04 
GeneralRe: Get the parent objet or parent level in nested lists Pin
norrisMiou5-Apr-10 7:26
norrisMiou5-Apr-10 7:26 
GeneralRe: Get the parent objet or parent level in nested lists Pin
Alan N5-Apr-10 13:19
Alan N5-Apr-10 13:19 
GeneralRe: Get the parent objet or parent level in nested lists Pin
norrisMiou5-Apr-10 15:29
norrisMiou5-Apr-10 15:29 
Yes That's it. You have explained my problem better than me.

I succeeded in doing about what I wanted.
In the "Add" method of my customTreeNodeCollection, I call a recursive function which looks at all the children (and nested children) and informs their properties “Level” and “ParentNode”.
So, when I add a root node to the custom collection of my custom TreeView, this function can inform all the nodes Smile | :)

My custom TreeNodeCollection
Public Class cTreeNodeCollection
    Inherits List(Of cNode)

    Public Overloads Sub Add(ByVal node As cNode)
        MyBase.Add(node)
        SetAllLevelsAndParents(node.ChildNodes, 1, node)
    End Sub

    Private Sub SetAllLevelsAndParents(ByVal nodeList As List(Of cNode), ByVal level As Int32, ByVal parentNode As cNode)
        For Each n As cNode In nodeList
            Console.WriteLine(level & " | " & n.Text)
            n.Level = level
            n.ParentNode = parentNode

            SetAllLevelsAndParents(n.ChildNodes, level + 1, n)
        Next
    End Sub
End Class


But your help will be very helpfull !
The answer for me, is to pass in parameters the current node and it's level for the recursive function.
With the level+1, i can inform the level of the childs, and with the node, I can inform the parent of the childs.

I don't know if it's a robust solution, but it seems working for the moment.
QuestionLinking Databases to VB Applications Pin
Razanust3-Apr-10 19:36
Razanust3-Apr-10 19:36 
AnswerRe: Linking Databases to VB Applications Pin
riced3-Apr-10 23:59
riced3-Apr-10 23:59 
AnswerRe: Linking Databases to VB Applications Pin
εїзεїзεїз4-Apr-10 0:19
εїзεїзεїз4-Apr-10 0:19 
GeneralRe: Linking Databases to VB Applications Pin
Razanust4-Apr-10 4:40
Razanust4-Apr-10 4:40 
GeneralRe: Linking Databases to VB Applications Pin
riced4-Apr-10 4:57
riced4-Apr-10 4:57 
AnswerRe: Linking Databases to VB Applications Pin
Luc Pattyn4-Apr-10 5:09
sitebuilderLuc Pattyn4-Apr-10 5:09 
AnswerRe: Linking Databases to VB Applications Pin
Luc Pattyn4-Apr-10 5:13
sitebuilderLuc Pattyn4-Apr-10 5:13 
GeneralRe: Linking Databases to VB Applications Pin
Razanust4-Apr-10 8:15
Razanust4-Apr-10 8:15 
QuestionProblem with unrar.dll and decompressor-class Pin
Maik Lange2-Apr-10 19:38
Maik Lange2-Apr-10 19:38 
AnswerRe: Problem with unrar.dll and decompressor-class Pin
Dave Kreskowiak3-Apr-10 3:02
mveDave Kreskowiak3-Apr-10 3:02 
AnswerRe: Problem with unrar.dll and decompressor-class Pin
Luc Pattyn3-Apr-10 4:59
sitebuilderLuc Pattyn3-Apr-10 4:59 
QuestionVB6 Extend maximum height of PictureBox Pin
Bob Hiller2-Apr-10 16:14
Bob Hiller2-Apr-10 16:14 
AnswerRe: VB6 Extend maximum height of PictureBox Pin
Dave Kreskowiak3-Apr-10 3:01
mveDave Kreskowiak3-Apr-10 3:01 
GeneralRe: VB6 Extend maximum height of PictureBox Pin
Luc Pattyn3-Apr-10 5:01
sitebuilderLuc Pattyn3-Apr-10 5:01 
GeneralRe: VB6 Extend maximum height of PictureBox Pin
Bob Hiller3-Apr-10 5:31
Bob Hiller3-Apr-10 5:31 
GeneralRe: VB6 Extend maximum height of PictureBox Pin
Dave Kreskowiak3-Apr-10 5:52
mveDave Kreskowiak3-Apr-10 5:52 
Generalwinmm Pin
FlavioAR2-Apr-10 12:26
FlavioAR2-Apr-10 12:26 

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.