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(node)
Sub treMain_AfterSelect( ... ) _
Handles treMain.AfterSelect
If TypeOf e.Node Is CustomNode Then
With DirectCast(e.Node, CustomNode)
.DoSomething()
End With
End If
End Sub
HTH,
Phill W.