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

Treeview

Scheduled Pinned Locked Moved C#
helpquestion
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
    StephenMcAllister
    wrote on last edited by
    #1

    With the standard treeview when a user right clicks a node to show a context menu the selected item does not change. I want to force this change. Is it possible and if so how? Thanks for any help.

    C S 2 Replies Last reply
    0
    • S StephenMcAllister

      With the standard treeview when a user right clicks a node to show a context menu the selected item does not change. I want to force this change. Is it possible and if so how? Thanks for any help.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      If there's an event you can catch for the right click, then a tree view has a method for finding the item under the mouse ( assuming it's not passed into the event handler ) and you can select it there. Christian Graus - Microsoft MVP - C++

      1 Reply Last reply
      0
      • S StephenMcAllister

        With the standard treeview when a user right clicks a node to show a context menu the selected item does not change. I want to force this change. Is it possible and if so how? Thanks for any help.

        S Offline
        S Offline
        S Senthil Kumar
        wrote on last edited by
        #3

        You can subscribe to the MouseDown event and use the following piece of code.

        if (e.Button == MouseButtons.Right)
        {
        TreeNode node = treeView.GetNodeAt(e.X, e.Y);
        if (node != null)
        treeView.SelectedNode = node;
        }

        Regards Senthil _____________________________ My Blog | My Articles | WinMacro

        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