Extending the TreeNode - - -> HELP!

  • Thread starter Thread starter Don
  • Start date Start date
D

Don

I've created a small test class to extend the Treenode object and am
having mixed success.

In the Treeview's 'BeforeExpand' event I've used code from the help
topic "Adding Custom Information to a TreeView or ListView Control"

I've been able to add nodes of myTreeNode type to the treeview and
verify that they really are myTreeNode type nodes but haven't been
able to get this part figured out.

Thank you for any help,

Don

The 'CType' line produces the following error:

'System.InvalidCastException'
Additional information: Specified cast is not valid.

Private Sub tvSnips_BeforeExpand(REMOVED) Handles tvSnips.BeforeExpand

Dim mynode As myTreeNode
mynode = CType(e.Node, myTreeNode) <-------ERROR
MessageBox.Show("Node selected is " & mynode.NodeParent)

End Sub


Public Class myTreeNode
Inherits TreeNode
Private mintParent As Integer

Public Enum enumNodeType
Dummy = -1
Group = 0
Leaf = 1
End Enum

Public nt As enumNodeType

Public Property NodeType() As enumNodeType
Get
Return nt
End Get
Set(ByVal Value As enumNodeType)
nt = Value
End Set
End Property

Public Property NodeParent() As Integer
Get
Return mintParent
End Get
Set(ByVal Value As Integer)
mintParent = Value
End Set
End Property
End Class
 
I believe they are but another smart person suggested the same thing.
I'll tripple check my code.

Thank you,

Don
 
Back
Top