Link to home
Start Free TrialLog in
Avatar of markp99
markp99

asked on

TreeView: Checked Node => Selected Node

I have a TreeView control in an app that works just fine, so far.

I am presently adding a CheckBox to the control to permit the user to select one or many nodes for "processing".
Currently, I can determine which nodes are checked by simply walking the tree (top-to-bottom) and testing the ".Checked" property...after they are already selected (via a separate button click).

Problem:

I want react to the actual NodeCheck event, but I am not able to determine the CurrentNode.  "Checking" a node does not actually SELECT the node.

Question:

Is there a way to determine the CHECKED node without walking down the tree and testing the ".Checked" property?


Thanks!
Avatar of rockiroads
rockiroads
Flag of United States of America image

Image if your treeview was called tvDB, u should be able to use the NodeClick handler


Private Sub tvDB_NodeClick(ByVal Node As Object)
    If Node.Text = Node.Key Then
        msgbox = "Top Root"
    Else
        Msgbox "Node.Text = " & Node.Text & vbcrlf & "Key is " & Node.Key
    End If
End Sub
urm, perhaps NodeClick may not work for what you want
Try it, see if you get a msgbox appearing


Can I suggest u try the other handlers?

the other one which checks for expansion is _Expand

there is also NodeCheck

Avatar of markp99
markp99

ASKER

Thanks rr,

I am already trapping the NodeCheck event, but this does not seem to provide the actual Node info (thus my question).

The NodeClick event is not triggered by the NodeCheck event.

/scratching head
Avatar of markp99

ASKER

Dang it,

It's always EASIER than I think it should be:

    Private Sub TreeView_NodeCheck(ByVal Node As Object)
        If Node.Checked Then
            MsgBox "Node " & Node.Text & " was checked"
        Else
            MsgBox "Node " & Node.Text & " was unchecked"
        End If
    End Sub


markp99
ASKER CERTIFIED SOLUTION
Avatar of rockiroads
rockiroads
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
bear in mind, Expand is only when you click on the + symbol
but I guess u already knew that!
Avatar of markp99

ASKER

I'll accept rr's comments, though my final solution was found elsewhere.

As noted above:

   Private Sub TreeView_NodeCheck(ByVal Node As Object)
        If Node.Checked Then
            MsgBox "Node " & Node.Text & " was checked"
        Else
            MsgBox "Node " & Node.Text & " was unchecked"
        End If
    End Sub
thanks for the acceptance, but you know if you feel one has not provided you with a satisfactory answer or you have found the solution yourself, u have the right to request a refund and close the question - u just need to post in the community support section.

but eh, glad its all working for you though. Good luck with the rest of your venture!