Drstein99 Posted December 10, 2003 Posted December 10, 2003 OK, I'm working with a treeview. I'm adding nodes, but their not regular node objects their custom objects: ----- Private Class nodeObject Inherits TreeNode Public Sub New(ByVal prmCode As String, ByVal prmTitle As String, ByVal prmIIndex As Integer) Text = prmTitle code = prmCode ImageIndex = prmIIndex End Sub Public code As String end class ----- and the line I use to add the object is: tvAccounts.Nodes.Item(0).Nodes.Add(New nodeObject("account_number","account_title", 1)) ---------- My question is: When users select an object on the node tree, it raises an "AfterSelect" event. The two paraments sent to the event are: ByVal sender As Object, ByVal e As TreeViewEventArgs Now how do i go about accessing the "nodeobject" custom node object to retrieve the "code" property? because .code isn't part of the standard .node member list. Please help. Thanks. Quote www.DRSTEIN99.com www.RAIDGEAR.net www.THERE.com -> Tell them DrStein99 sent ya!
Administrators PlausiblyDamp Posted December 11, 2003 Administrators Posted December 11, 2003 You could cast the sender object to the correct type dim theNode as nodeObject = DirectCast(sender, nodeObject) 'Then this should work dim s as string s= theNode.Code Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Drstein99 Posted December 11, 2003 Author Posted December 11, 2003 This works. However, I was having trouble casting this on a node that I didnt insert the custom nodeObject class in, so it was fault of my own I couldn't get it right the first time. Thanks! Quote www.DRSTEIN99.com www.RAIDGEAR.net www.THERE.com -> Tell them DrStein99 sent ya!
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.