adding new node at selected location

Mookie_jones

Member
Joined
Oct 23, 2005
Messages
16
Programming Experience
Beginner
i want to be able to press the enter key on my treeview and add a new node at that location, Im really struggling with this solution.
 
The TreeView itself has a Nodes property, as does each node. You just add the new TreeNode to the Nodes property of whatever you want to be its parent. If you want it at the highest level then you add it to the TreeView's Nodes collection.
 
i have no problem adding a node to the treeview. my problem is finding where in the treeview is currently selected, and then to add (append) a node from there.
 
I don't quite understand the problem. You're asking how to add a root node but you say you have no problem adding a node to the TreeView. You say you don't know how to find which node is selected yet the code you posted uses the SelectedNode property. What exactly is the issue? Are you saying that you don't know how to select the actual TreeView to be able to add a root node via the code you posted? If that's the case then the answer is that you can't. You would either have to provide a single root node, like My Computer in Windows Explorer, that the user could select and you could then add a new child node to using code similar to what you posted, or else add a seperate operation that specifically added a root node. If that's not the issue then please be more specific.
 
Back
Top