Results 1 to 2 of 2

Thread: TreeView Question

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2002
    Posts
    382

    TreeView Question

    I am trying to figure out how to determine the parent node of the selected node "if any". Basically I have a context menu that I display when a node is clicked but I have different menus for different nodes selected. How can I determine this?
    I have 3 Main parent nodes, index 0, 1, and 2, and I want to display this menu when a child node of parent node 0 is selected. anyone?


    Code:
        Private Sub trvMain_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles trvMain.MouseDown
    
            'Show the proper menu
            If e.Button = MouseButtons.Right AndAlso trvMain.SelectedNode.Index = 0 Then
                oMenu.MenuItems.Clear()
                oMenu.MenuItems.Add("New Zone", New EventHandler(AddressOf NewZone))
                oMenu.MenuItems.Add("Load Zone", New EventHandler(AddressOf LoadZone))
                oMenu.Show(trvMain, New Point(e.X, e.Y))
            End If

  2. #2
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    Try this....

    Code:
    If trv.SelectedNode.Parent.Index = 0 Then

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width