更新时间:2023-02-05 21:24:06
你甚至懒得阅读TreeNode上的文档,是吗? ?
每个TreeNode对象都有一个Parent,显然是指其父TreeNode。var parent = someChildNode.Parent;
我这样解决了:list.SelectedNode = list。 TopNode;
I currently have a treeview that gets populated with all the files and directories in the root directory. I need to select the parent directory of a child node programatically.
I have tried some code, but it only allows me to select the root directory, which is the first directory in the treeview and not the parent directory of the child node.
If someone could please help me, I would really appreciate it.
Thanks.
What I have tried:
list.SelectedNode = nodes[0];
You didn't even bother reading the documentation on TreeNode, did you?
Every TreeNode object has a Parent that, obviously, refers to its parent TreeNode.var parent = someChildNode.Parent;
I fixed it like this:list.SelectedNode=list.TopNode;