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. Capturing mouse events on a TreeNode

Capturing mouse events on a TreeNode

Scheduled Pinned Locked Moved .NET (Core and Framework)
comquestion
2 Posts 2 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
    Andrew Connell
    wrote on last edited by
    #1

    I've extended the TreeNode control to add an additional property. Now, what I'd like to do is capture the MouseDown event so I can perform some tasks when either the left or right mouse button is clicked. However, I can see that the TreeNode doesn't have any events to override. I tried capturing it with the TreeView control, but can't get the underlying object that was clicked. Any ideas? I was thinking about creating my own custom event in my extended control (TreeNodeExID)... but I can't find any examples or documentation... -AC Andrew Connell IM on MSN andrew@aconnell.com

    C 1 Reply Last reply
    0
    • A Andrew Connell

      I've extended the TreeNode control to add an additional property. Now, what I'd like to do is capture the MouseDown event so I can perform some tasks when either the left or right mouse button is clicked. However, I can see that the TreeNode doesn't have any events to override. I tried capturing it with the TreeView control, but can't get the underlying object that was clicked. Any ideas? I was thinking about creating my own custom event in my extended control (TreeNodeExID)... but I can't find any examples or documentation... -AC Andrew Connell IM on MSN andrew@aconnell.com

      C Offline
      C Offline
      Chris Rickard
      wrote on last edited by
      #2

      Override the WndProc procedure and handle the Windows Message WM_LBUTTONDOWN:

      class TreeNodeExID : TreeNode
      {
      ...
      public const int WM_LBUTTONDOWN = 0x0201;
      protected override void WndProc(ref Message m)
      {
      if(m.Msg == WM_LBUTTONDOWN)
      {
      //DO WORK HERE
      }
      base.WndProc(ref m);
      }
      }

      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