Is there any way I can disable expanding TreeNode after doubleclick??
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is no simple way to achieve this, as far as I know. One thought would be to have a
boolvariable set totrueon the DoubleClick event, and use thee.Cancelproperty of theBeforeExpandevent to prevent the node from expanding. However, those two events are fired in the opposite order, so that is not a solution. I don’t have another solution from the top of my head; will update if I come up with one.Update
I have played around with this a bit, and I have found one way that works reasonably well. As I have mentioned the problem is that
BeforeExpandhappens beforeDoubleClick, so we can’t set any state inDoubleClickto use inBeforeExpand.We can, however, detect (potential) double clicks in another way: by measuring the time between
MouseDownevents. If we get twoMouseDownevents within the time period that defines a double click (as stated inSystemInformation.DoubleClickTime), it should be a double click, right? And theMouseDownevent is raised beforeBeforeExpand. So, the following code works rather well:I say “rather well” because I feel that it prevents the node from expanding in some cases when it should not (for instance if you within the double click time click first on the node text and then on the plus sign). That might be possible to solve in some way, or perhaps you can live with that.