views:

1663

answers:

1

Hi all,

Is there a simple way to disable the auto-expand/collapse of a TreeView node when it is double-clicked? I've been unable to find an answer to this question that works without checking in BeforeExpand/BeforeCollapse if the current system time matches that expected for a double-click - overriding OnNodeMouseDoubleClick and/or OnDoubleClick does not seem to suffice.

Or, is checking the system time and seeing if it fits a double-click the only way to do this?

Thanks for your help, -Walt

+2  A: 

Solved: Actually, the entire solution was at http://www.developersdex.com/gurus/code/831.asp . Apparently OnNodeMouseDoubleClick() is not called in the WM_LBUTTONDBLCLK handler for TreeView at all . . . it's called in the LBUTTONUP handler. So, The following is what's at that site:

    protected override void DefWndProc(ref Message m) {
        if (m.Msg == 515) { /* WM_LBUTTONDBLCLK */
        }
        else
            base.DefWndProc(ref m);
    }

If you want to halt handling to the left of the node, then in OnNodeMouseDoubleClick() do the following:

if (e.X >= e.Node.Bounds.Left) {
    return;
}
Walt W