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. C#
  4. TreeView and right click select?

TreeView and right click select?

Scheduled Pinned Locked Moved C#
question
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.
  • S Offline
    S Offline
    se99ts
    wrote on last edited by
    #1

    I have added a context menu to my TreeView, but when i use TreeView.SelectedNode it doesnt return the node that the user right clicked on only the node that was last left clicked. Is there anyway to get a TreeView to select the node the mouse is over on right click? Thanks Tim

    M L 2 Replies Last reply
    0
    • S se99ts

      I have added a context menu to my TreeView, but when i use TreeView.SelectedNode it doesnt return the node that the user right clicked on only the node that was last left clicked. Is there anyway to get a TreeView to select the node the mouse is over on right click? Thanks Tim

      M Offline
      M Offline
      mikasa
      wrote on last edited by
      #2

      Use the "GetNodeAt" Function on the MouseDown event of the TreeView and then Set the SelectedNode to that one.

      1 Reply Last reply
      0
      • S se99ts

        I have added a context menu to my TreeView, but when i use TreeView.SelectedNode it doesnt return the node that the user right clicked on only the node that was last left clicked. Is there anyway to get a TreeView to select the node the mouse is over on right click? Thanks Tim

        L Offline
        L Offline
        Leon van Wyk
        wrote on last edited by
        #3

        Use the MouseUp Event for the TreeView and get the current mouse position. Then you can Use the TreeView.GetNodeAt(X,Y), here follows the code. The TreeView was called FolderTreeView! private void FolderTreeView_MouseUp (object sender ,System.Windows.Forms.MouseEventArgs e) {//MouseButton Released try { //Select the Node Under the Mouse Cursor as Current Node FolderTreeView.SelectedNode = FolderTreeView.GetNodeAt(e.X,e.Y); } } Leon v Wyk

        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