Last post Mar 15, 2008 09:05 PM by sensoryoverlord7
Mar 15, 2008 09:05 PM|sensoryoverlord7|LINK
I am creating a databasetreeview so I have a custom function that loads the treeview from a database. It works! (almost) actually it gives me a type cast exception.
I have created a DatabaseTreeNode class, and I add the nodes to the list by doing:
TreeNode t = new DatabaseTreeNode();
this.Nodes.Add ( t );
or something similar
So heres the problem:
I want to execute the following line:
DatabaseTreeNode t = (DatabaseTreeNode) TreeView1.SelectedNode;
but I get an invalid class cast exception because it thinks the selectedNode is a TreeNode. I can actually cast one of the TreeView1.Nodes to a DatabaseTreeNode no problem.
SelectedNode seems to be a reference to a reference in the TreeView1.Nodes collection that refers to the actual DatabaseTreeNode object. I can see in the SelectedNode from the debugger that there is a private variable called _owner that refers to my DatabaseTreeNode...
so I'm just wondering if anyone knows how I could possibly dereference it?