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