PDA

View Full Version : TreeView_NodeCheck Event



SailePaty
03-30-2006, 07:55 PM
Hi,

I have a Treeview control and want the Root Node.Checked property be set in base a cell value.

I’m using the below code that sets the correct property to the node. However, as soon de procedure finished the Node.Checked property takes the status it got when the checked event occurred.


Private Sub TreeView1_NodeCheck(ByVal Node As MSComctlLib.Node)

If Node.Index <> 1 Then Exit Sub

If Range("Root_Included").Value = "No" Then Node.Checked = False

If Range("Root_Included").Value = "Yes" Then Node.Checked = True

End Sub



Any ideas how I can keep the property set in the procedure?

Thanks in advance.

SailePaty
03-31-2006, 08:39 PM
Finally I got some way to work around this issue. I know this is not the best way but it makes what I was looking for.

So, here it is in case somebody else has the same problem.


Option Explicit
Private Node_Root As Node
Private Node_Status As Boolean
Private Node_Check_Status As Boolean

Private Sub TreeView1_NodeCheck(ByVal Node As MSComctlLib.Node)
If Node.Index <> 1 Then Exit Sub 'In case is not the Root Node
If Range("Root_Included").Value = "No" Then Node_Status = False
If Range("Root_Included").Value = "Yes" Then Node_Status = True
Set Node_Root = Node
Node_Check_Status = True
End Sub

Private Sub TreeView1_Click()
If Node_Check_Status Then
Node_Root.Checked = Node_Status
Node_Check_Status = False
End If
End Sub


Regards