|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Extending the TreeNode - - -> HELP!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 Are ALL the nodes in the tree of type myTreeNode?
Show quote "Don" <don81846@NO_CaCa.Earthlink.net> wrote in message news:b81v02p4414sast0l7l101064qoo4qvcc9@4ax.com... > > 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 On Thu, 09 Mar 2006 07:56:01 GMT, "Nick Hounsome" <nh***@nickhounsome.me.uk> wrote: Show quote >Are ALL the nodes in the tree of type myTreeNode? > >"Don" <don81846@NO_CaCa.Earthlink.net> wrote in message >news:b81v02p4414sast0l7l101064qoo4qvcc9@4ax.com... >> >> 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 >> |
|||||||||||||||||||||||