Results 1 to 2 of 2

Thread: [RESOLVED][VB6][TREEVIEW] How to unchecked the treeview node

  1. #1

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    [RESOLVED][VB6][TREEVIEW] How to unchecked the treeview node

    I would like to make a function for the user, when a user checked any of the parent node, the entire of child node and parent node will checked.
    I tried to write on myself. The child node will checked if checked on parent node. However, i can't unchecked the child node if parent node unchecked.

    Code:
    Dim IndentifyCheck As Integer
    Dim nodMP As Node
    Dim nodP As Node
    identifycheck = 0
       If Node.Checked = True Then
           If Not Node.Parent Is Nothing Then ' Parent exist.
                Node.Parent.Checked = True
                If Not Node.Parent.Parent Is Nothing Then
                    Node.Parent.Parent.Checked = True
                End If
                    
           End If
           If Not Node.Child Is Nothing Then
              Set nodMP = Node.Child
                Do Until nodMP Is Nothing
                    nodMP.Checked = True
                    If Not nodMP Is Nothing Then
                        Set nodP = nodMP.Child
                        Do Until nodP Is Nothing
                            nodP.Checked = True
                            Set nodP = nodP.Next
                        Loop
                        
                    End If
                Set nodMP = nodMP.Next
                Loop
                
           End If
       Else
           Do Until Node = Node.LastSibling
              If Node.Checked Then
                  identifycheck = identifycheck + 1
              End If
              Set Node = Node.Next
           Loop
           If identifycheck < 1 Then
                If Not Node.Parent Is Nothing Then
                    Node.Parent.Checked = False
                        If Not Node.Parent.Parent Is Nothing Then
                            Node.Parent.Parent.Checked = False
                        End If
                End If
           End If
           If Not Node.Child Is Nothing Then
              Set nodMP = Node.Child
                Do Until nodMP Is Nothing
                    nodMP.Checked = False
                    If Not nodMP Is Nothing Then
                        Set nodP = nodMP.Child
                        Do Until nodP Is Nothing
                            nodP.Checked = False
                            Set nodP = nodP.Next
                        Loop
                        
                    End If
                Set nodMP = nodMP.Next
                Loop
                
           End If
           
       End If
    Last edited by nUflAvOrS; Aug 24th, 2007 at 05:26 AM.
    Where there is no hope, there can be no endeavor.

    There are two ways of rising in the world, either by your own industry or by the folly of others.

  2. #2

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Re: [VB6][TREEVIEW] How to unchecked the treeview node

    Quote Originally Posted by nUflAvOrS
    I would like to make a function for the user, when a user checked any of the parent node, the entire of child node and parent node will checked.
    I tried to write on myself. The child node will checked if checked on parent node. However, i can't unchecked the child node if parent node unchecked.

    Code:
    Dim IndentifyCheck As Integer
    Dim nodMP As Node
    Dim nodP As Node
    identifycheck = 0
       If Node.Checked = True Then
           If Not Node.Parent Is Nothing Then ' Parent exist.
                Node.Parent.Checked = True
                If Not Node.Parent.Parent Is Nothing Then
                    Node.Parent.Parent.Checked = True
                End If
                    
           End If
           If Not Node.Child Is Nothing Then
              Set nodMP = Node.Child
                Do Until nodMP Is Nothing
                    nodMP.Checked = True
                    If Not nodMP Is Nothing Then
                        Set nodP = nodMP.Child
                        Do Until nodP Is Nothing
                            nodP.Checked = True
                            Set nodP = nodP.Next
                        Loop
                        
                    End If
                Set nodMP = nodMP.Next
                Loop
                
           End If
       Else
    If Not Node.Child Is Nothing Then
              Set nodMP = Node.Child
                Do Until nodMP Is Nothing
                    nodMP.Checked = False
                    If Not nodMP Is Nothing Then
                        Set nodP = nodMP.Child
                        Do Until nodP Is Nothing
                            nodP.Checked = False
                            Set nodP = nodP.Next
                        Loop
                        
                    End If
                Set nodMP = nodMP.Next
                Loop
                
           End If
           Do Until Node = Node.LastSibling
              If Node.Checked Then
                  identifycheck = identifycheck + 1
              End If
              Set Node = Node.Next
           Loop
           If identifycheck < 1 Then
                If Not Node.Parent Is Nothing Then
                    Node.Parent.Checked = False
                        If Not Node.Parent.Parent Is Nothing Then
                            Node.Parent.Parent.Checked = False
                        End If
                End If
           End If
                  
       End If
    I SOLVED THE PROBLEM WRONG SEQUENCE OF NODE I DID.
    Where there is no hope, there can be no endeavor.

    There are two ways of rising in the world, either by your own industry or by the folly of others.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width