Tree view problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Omar Abid

    #1

    Tree view problem

    Hi,
    I'm using a tree view to manage my tables.
    The nodes are made dynamiclly, the problem that I want to create an
    event when I select a node. I used the code below
    treeview.select ednode.index = 0
    but when I use that code the event run on all nodes and children nodes
    I want to associate an index to each node to resolve that problem
    Does any one had solution
    Omar Abid

  • Phillip Ross Taylor

    #2
    Re: Tree view problem

    On 14 Jun, 12:01, Omar Abid <omar.abid2...@ gmail.comwrote:
    Hi,
    I'm using a tree view to manage my tables.
    The nodes are made dynamiclly, the problem that I want to create an
    event when I select a node. I used the code below
    treeview.select ednode.index = 0
    but when I use that code the event run on all nodes and children nodes
    I want to associate an index to each node to resolve that problem
    Does any one had solution
    Omar Abid
    When a user clicks / selects a node the "AfterSelec t" event fires. You
    can then probe tree1.selectedn odes to see what exactly was selected.

    You can also create an OnMouseDown event for the tree and add the
    line:

    treMain.Selecte dNode = treMain.GetNode At(e.X, e.Y)

    And finally there is an event called "NodeMouseClick " which you can
    use to signal something has been clicked and take the appropriate
    action.

    But it's hard for me to understand what your trying to do.

    Comment

    • Omar Abid

      #3
      Re: Tree view problem

      On 14 juin, 15:15, Phillip Ross Taylor <Phillip.Ross.T ay...@gmail.com >
      wrote:
      On 14 Jun, 12:01, Omar Abid <omar.abid2...@ gmail.comwrote:
      >
      Hi,
      I'm using a tree view to manage my tables.
      The nodes are made dynamiclly, the problem that I want to create an
      event when I select a node. I used the code below
      treeview.select ednode.index = 0
      but when I use that code the event run on all nodes and children nodes
      I want to associate an index to each node to resolve that problem
      Does any one had solution
      Omar Abid
      >
      When a user clicks / selects a node the "AfterSelec t" event fires. You
      can then probe tree1.selectedn odes to see what exactly was selected.
      >
      You can also create an OnMouseDown event for the tree and add the
      line:
      >
      treMain.Selecte dNode = treMain.GetNode At(e.X, e.Y)
      >
      And finally there is an event called "NodeMouseClick " which you can
      use to signal something has been clicked and take the appropriate
      action.
      >
      But it's hard for me to understand what your trying to do.
      The problem is the node. I want to attribute to each note an index so
      i can add to each node a special event
      How to do that ?

      Comment

      • Phill W.

        #4
        Re: Tree view problem

        Omar Abid wrote:
        The problem is the node. I want to attribute to each node an index so
        i can add to each node a special event
        Why bother?

        Derive your own TreeNode class and add instances of this to the TreeView.
        In the Tree's AfterSelect event, test the Type of the node that was
        clicked on and, if it's one of yours, invoke the required method.

        Class CustomNode
        Inherits TreeNode

        Private Sub New()
        End Sub

        Public Sub New( ByVal sText As String )
        MyBase.Text = sText
        End Sub

        Public Sub DoSomething()
        End Sub

        End Class

        Dim node As New CustomNode( "Fred" )
        treMain.Add(nod e)

        Sub treMain_AfterSe lect( ... ) _
        Handles treMain.AfterSe lect

        If TypeOf e.Node Is CustomNode Then
        With DirectCast(e.No de, CustomNode)
        .DoSomething()
        End With
        End If

        End Sub

        HTH,
        Phill W.

        Comment

        Working...