Consulting

Results 1 to 2 of 2

Thread: TreeView_NodeCheck Event

  1. #1

    TreeView_NodeCheck Event

    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.

    [vba]
    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

    [/vba]

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

    Thanks in advance.

  2. #2
    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.

    [vba]
    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
    [/vba]

    Regards

Posting Permissions

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