Can you disable the Treeview double-click expanding of nodes?

Posted on 2008-11-12
Last Modified: 2012-05-05
I am trying to do some custom action with a treeview when a node is double-clicked.  The problem is that even when I don't have my own doubleclick event handler, the Treeview uses the double-click to automatically expand or contract an expandable node.  Is there a way to turn off this behavior?  It would be ideal if the nodes would only expand/contract if the +/- box on the node were clicked, and the double-click could be for the custom action.
Question by:srbentley
    LVL 1

    Expert Comment

    You can easily disable the expansion of tree-view on user double-click by ;
    Go in to the treeview node editor and then in the properties set the 'SelectAction' property to 'Select' or 'None' so as to disable the doubl-click behaviour.

    Author Comment

    I'm adding the nodes dynamically and I was going to use the SelectAction as mentioned, but that property is not available??? I tried to do a MyNode.SelectAction but does not find it in Visual Studio 2008.
                    MyNode = New TreeNode
                    MyNode.Name = "S" & CStr(dr.Item(0))
                    MyNode.Text = dr.Item(2)
                    MyNode.Tag = "SECTION-" & dr.Item(2)
                    MyNode = Nothing

    Open in new window

    LVL 1

    Accepted Solution

    Try adding a node in the design view by clicking the Smart tag for the treeview control , add a node and  see if its 'SelectAction' property is available.

    Author Comment

    I see now why it is not available... this TreeView is inside a usercontrol and so my Nodes are System.Windows.Form.TreeNode not System.Web.UI.WebControls.TreeNode.  The SelectAction is not in the windows.form version.  My control had Imports System.Web.  I tried imporing System.Web.UI.WebControls, then it broke the code I showed earlier.  Can you even put a WebControl version of the treeview into a UserControl?  I don't see it on the Toolbar or does it have to be done programatically?

    Author Comment

    Your tip of using SelectAction didn't fix my problem, but it did put me on the right path to finding the solution.  I have moved this question to the section since I'm doing a Usercontrol inside of, and thus it really is a issue.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    I have developed many web applications with asp & and to add and use a dropdownlist was always a very simple task, but with the new, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
    In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    This video discusses moving either the default database or any database to a new volume.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now