Is there an event that fires when the text of a TreeNode is clicked?

I have a page which contains a TreeView control. Each of the TreeNodes has it's ShowCheckBox attribute set to True.

Under the TreeView is a button which carries out actions, based on the nodes that are ticked in the TreeView, this works fine.

What I would like to do is define another action (independent of the ticked/unticked state) which fires whenever the text of the node is clicked.

Is there a way to do this?
LVL 1
rpmAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rgonzo1971Commented:
HI,

maybe
TreeView.BeforeLabelEdit

Open in new window

https://msdn.microsoft.com/en-us/library/system.windows.forms.treeview.beforelabeledit(v=vs.110).aspx

Regards
0
rpmAuthor Commented:
I'm not seeing that event in Visual Studio
0
ArkCommented:
    Private Sub TreeView1_NodeMouseClick(sender As Object, e As System.Windows.Forms.TreeNodeMouseClickEventArgs) Handles TreeView1.NodeMouseClick
        Dim ht = TreeView1.HitTest(e.Location)
        Dim nd = ht.Node
        If nd Is Nothing Then Return
        If ht.Location = TreeViewHitTestLocations.Label Then 
            nd.Checked = Not nd.Checked
        End If
    End Sub

Open in new window

0
rpmAuthor Commented:
I'm getting:
 Error      13      Event 'NodeMouseClick' cannot be found.
0
ArkCommented:
Oh, I see - this is web app, not windows app. In this case:
Option 1 - using SelectedNodeChanged event
    Private Sub TreeView1_SelectedNodeChanged(sender As Object, e As System.EventArgs) Handles TreeView1.SelectedNodeChanged
        TreeView1.SelectedNode.Checked = Not TreeView1.SelectedNode.Checked
        TreeView1.SelectedNode.Selected = False
    End Sub

Open in new window

Option 2 - using client side script: https://www.aspsnippets.com/Articles/ASP.Net-TreeView---Handle-node-onclick-event-client-side-using-JavaScript.aspx
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.