获取所选树节点的参考 [英] Getting the reference of the selected treenode

查看:137
本文介绍了获取所选树节点的参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我在Windows窗体应用程序中有一个树视图,该树视图是从diffrent xml文件(不同的节点diffrent xml文件)填充的,我需要所选节点的确切路径(xml文件位置).
任何人都可以帮助我
预先感谢


i have a tree view in windows form application which is populated from the diffrent xml files(diffrent nodes diffrent xml files) i need the Exact path(the xml file location) of the node which is selected.
Any one pls help me
Thanks in advance

推荐答案

使用其Parent属性从选定节点移动到其父节点,并相应地修改路径结构.您可以使用递归,但是您不需要它,因此最好使用循环,直到父级为null.

—SA
Move from a selected node to its parent using its Parent property and modify the path structure accordingly. You can use recursion but you don''t need it, so better use a cycle until the parent is null.

—SA


您可以将XML文件位置存储在节点的Tag属性中

You can store the XML file location in the Tag attributes of the node

private void tvFileMaps_MouseClick(object sender, MouseEventArgs e)
{
    TreeNode tn = SelectedTree.GetNodeAt(e.Location.X, e.Location.Y);
    string XMLLocation = tn.Tag != null ? tn.Tag.ToString() : string.Empty;
}


在TreeView中添加TreeNode时,请添加Tag 属性以及XML文件的位置.


At the time of adding the TreeNode in the treeView add the Tag property with the location of the XML file.


这篇关于获取所选树节点的参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆