Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. DoubleClick in TreeView

DoubleClick in TreeView

Scheduled Pinned Locked Moved .NET (Core and Framework)
tutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    Hey, How to turn off behaviour of TreeView control that if you double click on branch with children than it will expand/collapse? Overriding OnDoubleClick() doesn't work as some other event does collapse/expand.

    L J 2 Replies Last reply
    0
    • A Anonymous

      Hey, How to turn off behaviour of TreeView control that if you double click on branch with children than it will expand/collapse? Overriding OnDoubleClick() doesn't work as some other event does collapse/expand.

      L Offline
      L Offline
      LasVegasGuy
      wrote on last edited by
      #2

      I am assuming that the "OnDOubleClick" function you are talking about is a function you implemented as a callback in the parent window class, to process the NM_DBLCLK notification message from the tree control. This message is sent to the parent window AFTER the tree control finishes its default processing. You need to subclass the tree control and handle the WM_LBUTTONDBLCK message appropriately.

      1 Reply Last reply
      0
      • A Anonymous

        Hey, How to turn off behaviour of TreeView control that if you double click on branch with children than it will expand/collapse? Overriding OnDoubleClick() doesn't work as some other event does collapse/expand.

        J Offline
        J Offline
        John Arlen
        wrote on last edited by
        #3

        Solution de Uberness: ----------------------------------------------- using System; namespace UberControls { public class TreeViewNonExpanding : System.Windows.Forms.TreeView { private bool incomingDoubleClick = false; protected override void WndProc(ref System.Windows.Forms.Message m) { switch( m.Msg ) { case 0x0203: // WM_LBUTTONDBLCLK this.incomingDoubleClick = true; break; case 0x0202: // WM_LBUTTONUP this.incomingDoubleClick = false; break; default: break; } base.WndProc (ref m); } protected override void OnBeforeExpand(System.Windows.Forms.TreeViewCancelEventArgs e) { if( incomingDoubleClick == true ) e.Cancel = true; base.OnBeforeExpand (e); } } }

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups