Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / March 2006

Tip: Looking for answers? Try searching our database.

Extending the TreeNode  - - -> HELP!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Don - 09 Mar 2006 01:30 GMT
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
Nick Hounsome - 09 Mar 2006 07:56 GMT
Are ALL the nodes in the tree of type myTreeNode?

> I've created a small test class to extend the Treenode object and am
> having mixed success.
[quoted text clipped - 53 lines]
>    End Property
> End Class
Don - 09 Mar 2006 21:42 GMT
I believe they are but another smart person suggested the same thing.
I'll tripple check my code.

Thank you,

    Don

>Are ALL the nodes in the tree of type myTreeNode?
>
[quoted text clipped - 11 lines]
>>
>> Don

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.